新版本webpack生成的dev.server.js 在webpack.dev.conf.js中
webpack.dev.conf.js
const axios = require('axios')
const express = require('express')
const app = express()
const apiRoutes = express.Router()
app.use('/api', apiRoutes)
然后找到devserver 这里可以配置路由
devServer: {
before (app) {
app.get('/api/getDiscList', function (req, res) {
res.json
})
},
转载于:https://www.cnblogs.com/luxiaoyao/p/8733832.html