Add the setupproxy.js file to the SRC folder

Setupproxy.js (new) Axios cannot configure baseURL:

const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
  app.use(
    '/edu',
    createProxyMiddleware({
      target: 'http://test_zhiliao.gongzuoshouji.cn'.changeOrigin: true,}}))Copy the code

 

Setupproxy.js (old)

const proxy = require('http-proxy-middleware')

module.exports = function(app) {
  app.use(
    proxy('/api', {
      target: 'http://localhost:85'.secure: false.changeOrigin: true.pathRewrite: {
        "^/api": "/api"}}}))Copy the code

Restart the project.

Note that the axios default request address does not change. To the front end, the interface is as if it were on port 3000, with no proxy configuration at all.