Modern.js provides a way to configure the development proxy in tools.devServer. For example, to proxy the local interface to an online address:
import { defineConfig } from '@modern-js/app-tools';
export default defineConfig({
tools: {
devServer: {
proxy: {
'/go/api': {
target: 'http://www.example.com/',
changeOrigin: true,
},
},
},
},
});When access http://localhost:8080/go/api, the response content will be returned from http://www.example.com/.
For more detail, see http-proxy-middleware.