Angular 6 proxy not working anymore

2019-03-02 13:54发布

问题:

I have an angular application and one web api. To test is locally, I use a proxy config file: proxy.conf.json

{
"/api": {
    "target": {
        "host": "localhost",
        "protocol": "http:",
        "port": 50565
    },
    "secure": false,
    "changeOrigin": false,
    "logLevel": "info"
    }
}

Everything was working fine. Recently I updated to ng6. Since then I get the following error:

[HPM] Error occurred while trying to proxy request /api/data/GetCurrentUser/ from localhost:4200 to http://localhost:50565 (ECONNREFUSED)

Any idea what's going on here? (I use ng serve --proxy-config proxy.conf.json)

回答1:

Please try


"changeOrigin": true



标签: angular proxy