index.js
fetch('/api/zxcv').then(res => res.json()).then(res => {
console.log(res)
})
webpack.config.js
const htmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './src/index.js',
mode: 'development',
devServer: {
proxy: {
'/api': {
target: 'http://127.0.0.1:9000',
}
}
},
plugins: [
new htmlWebpackPlugin(),
],
}
小心重定向缓存
网友评论