I'm using electron-react-boilerplate
set proxy in webpack devServer, but not work
The directory structure of this project is as follows:
use axios
const BASE_URL = process.env.NODE_ENV !== 'production' ? ORIGIN + '/api' : ORIGIN;
const instance = axios.create({
baseURL: BASE_URL,
timeout: 50000,
});
webpack.config.render.dev.ts
devServer: {
port,
compress: true,
hot: true,
// headers: { 'Access-Control-Allow-Origin': '*' },
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers':
'X-Requested-With, content-type, Authorization',
},
static: {
publicPath: '/',
},
proxy: {
'/api': {
target: 'http://xxx.xx.xx.xxx:18080',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
},
...
}
Is there an error in my configuration?

