It doesn't work to use proxy in webpack's devServer to solve cross-domain problems.

use webpack to open the front page on the local localhost:8080 port
proxy is configured like this:

    devServer: {
        port: 8080,
        contentBase: "./dist",
        proxy: {
            "/abc": {
                target: "http://122.79.10.259:8080"
            }
        }
    },

the code that uses the ajax request on the page looks like this:

    $.ajax({
        url: "/abc/signup/video",
        type: "get"
    }).done(res => {

    }).fail(err => {

    })

at this point, the browser still asks for http://localhost:8080/abc/signup/video, instead of http://122.79.10.259:8080/abc/signup/video
, ask the gods to help solve the problem.


1. First of all, the browser is right to request http://localhost:8080/abc/signup/video. The outgoing request is received by dev-server and then forwarded to the destination address, which is equivalent to the agent
2. Do not take effect is your configuration is wrong, your main configuration of the final request address should be http://122.79.10.259:8080/signup/video


I also encountered the same problem, the agent is not successful, return 404

Menu