As soon as I make a post request to the api from the web app I am working on, I get the above error.It works fine with the get requests made.Is there any specific reason for getting this error? I tried one of the solutions mentioned on StackOverflow by enabling a chrome extension but that didn't solve the problem. Is there any other way to solve it. I get same error with Mozilla too.
Asked
Active
Viewed 72 times
0
-
1What's the CORS policy on the server? Sounds like it only allows CORS `GET` requests – Mark C. Aug 22 '18 at 15:21
-
What api are you working with ? – Ennar.ch Aug 22 '18 at 15:21
-
It is not a public api. – jammy Aug 22 '18 at 15:23
1 Answers
-1
If you try to send request to api cross different origins(CORS). You need to set Access-Control-Allow-Origin for your Response server.
For example:
Sending request to Twitch API server and get response from API server
Content-Type: application/json
Content-Length: 71
Connection: keep-alive
Server: nginx
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, must-revalidate, private
Expires: 0
Pragma: no-cache
Twitch-Trace-Id: e316ddcf2fa38a659fa95af9012c9358
X-Ctxlog-Logid: 1-5920052c-446a91950e3abed21a360bd5
Timing-Allow-Origin: https://www.twitch.tv
Access-Control-Allow-Origin: * means that you can send request from any origin.

Angela Lai
- 1
- 4