0

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.

jammy
  • 857
  • 2
  • 18
  • 34

1 Answers1

-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.