vue-cli 2.92版本 server
一 、引包 const axios = require('axios'); const express = require('express'); const apiRoutes = express.Router(); 二、配置 const devWebpackConfig = merge(baseWebpackConfig, { module: { rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap, usePostCSS: true}) }, // cheap-module-eval-source-map is faster for development devtool: config.dev.devtool, // these devServer options should be customized in /config/index.js devServer:{ //在这里添加一个before方法 before(apiRoutes){ apiRoutes.get('/api/getDiscList',(req,res)= > { const url = '这里是要链接的api地址'; axios.get(url, { headers: { referer: '配置api地址referer',