前端只想单纯mock数据 「跨域」
devServer: {
// proxy: {
// '/api': 'http://localhost:3000' // 配置一个代理
// }
// proxy: { // 重写方式 把请求代理到express 上
// '/api': {
// target: 'http://localhost:3000',
// pathRewrite: {'^/api': ''}
// }
// }
before: function (app) { // 勾子
app.get('/api/user', (req, res) => {
res.json({name: 'mayufo - before'})
})
}
},