Deadly CORS when http://localhost is the origin

后端 未结 9 1317
迷失自我
迷失自我 2020-11-22 00:54

I am stuck with this CORS problem, even though I set the server (nginx/node.js) with the appropriate headers.

I can see in Chrome Network pane -> Response Headers:

9条回答
  •  忘了有多久
    2020-11-22 01:35

    None of the extensions worked for me, so I installed a simple local proxy. In my case https://www.npmjs.com/package/local-cors-proxy It is a 2-minute setup:

    (from their site)

    npm install -g local-cors-proxy
    

    API endpoint that we want to request that has CORS issues: https://www.yourdomain.ie/movies/list

    Start Proxy: lcp --proxyUrl https://www.yourdomain.ie

    Then in your client code, new API endpoint: http://localhost:8010/proxy/movies/list

    Worked like a charm for me: your app calls the proxy, who calls the server. Zero CORS problems.

提交回复
热议问题