For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guides/basic-features/debug/proxy.md.
  • 简体中文
  • 本地代理

    Modern.js 在 dev.server.proxy 中提供了配置开发环境代理的方式。

    例如,将本地开发接口代理到其他地址:

    modern.config.ts
    import { defineConfig } from '@modern-js/app-tools';
    
    export default defineConfig({
      dev: {
        server: {
          proxy: {
            // http://localhost:8080/api -> https://example.com/api
            // http://localhost:8080/api/foo -> https://example.com/api/foo
            '/api': 'https://example.com',
          },
        },
      },
    });