Preflight response is not successful Preflight response is not successful angularjs angularjs

Preflight response is not successful


You should add the address of your requesting site URL in CORS in your Server/Backend code. Each language or framework might have their own way of adding this, try to search "[backend language] cors" (e.g. "C# cors") in google. (credits to @Gary Liu - MSFT)

You can confirm you have added correct origin by inspecting network tab in developer's console.

First select the request with method OPTIONSenter image description here

Then verify the Access-Control-Allow-Origin is the same with your Originenter image description here


How about setting up a proxy instead?

proxy.config.json

{  "/api/contacts" : {    "target": "http://{{webapp name}}.azurewebsites.net/api/contacts",    "secure": "false,    "changeOrigin": true,    "pathRewrite": {      "^/api/contacts/": ""    }  }}

You can find more details on https://angular.io/guide/build#proxying-to-a-backend-server