HTTP request from Angular sent as OPTIONS instead of POST

前端 未结 5 676
孤街浪徒
孤街浪徒 2020-12-03 04:59

I\'m trying to send some HTTP requests from my angular.js application to my server, but I need to solve some CORS errors.

The HTTP request is made using the followin

5条回答
  •  时光取名叫无心
    2020-12-03 05:16

    The best is to

    1. have proxy.conf.json set:
        {
          "/api": {
            "target": "http://localhost:8080",
            "secure": false,
            "logLevel": "debug",
            "changeOrigin": true
          }
        } 
    
    1. And then to make sure that URL that you are using in angular to send a request is relative (/api/something) and not absolute (localhost:8080/api/something). Because in that case the proxy won't work.

    Good luck!

提交回复
热议问题