Cross-domain problem of vue project access background interface

problem description

vue project axios requests background interface and uses webpack proxy to solve cross-domain problems. Report 404

the environmental background of the problems and what methods you have tried

vue project is based on vue-admin-tempalte
webpack 4.x
vue 2.0

related codes

/ / Please paste the code text below (do not replace the code with pictures)
config/index.js file

proxyTable: {
    "/api": {
        target: "http://127.0.0.1:9000",
        pathRewrite: {"^/api" : ""}
    }
}

config/dev.env.js file
(this file is written as a template and can be referenced by vue-admin-tempalte "s friends. This problem can be ignored)

module.exports = merge(prodEnv, {
    NODE_ENV: ""development"",
    BASE_API: ""/""
})

api request file

export function fetchList() {
    return request({
        url: "/api/deeplearning/test",
        method: "get"
    })
}
What is the error message that

actually sees?

you can see from the api request that proxy forwarding can be completed by setting url to / api/deeplearning/test, through proxyTable, and
will remove the prefix / api to rewrite url,. The request currently seen by F12 in the browser is
http://localhost:8080/deeplearning/test/ 8080 is my vue project port, in which Filter has been dropped / api, indicates that proxyTable configuration has been taken, but still reported 404. The back-end interface can be accessed normally, and the access address of
is http://127.0.0.1:9000/deeplearning/test/. Now there are questions:
1. In this case where url rewriting has been implemented, could it still be a problem with proxy configuration?
2. If the agent configuration is fine, how do you locate the problem? does it have anything to do with axios?

look forward to thanking you for your doubts!


configure the agent to re-run dev.


if you and the backend are in a local area network, first ping his ip, to see if it can't get through, and then put the path of your request to the browser to open it directly, reporting that the 405 interface is open, cross-domain is that he does not set the request header at the backend, 403 is that the gateway does not penetrate, you need to set it at the backend, and if you report 404, his ip is not connected at all. Remember to restart the project after configuring the agent

Menu