Created
August 6, 2015 10:36
-
-
Save gon250/9aa6075c3662254073af to your computer and use it in GitHub Desktop.
Enable cors domain in the web.config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<httpProtocol> | |
<customHeaders> | |
<add name="Access-Control-Allow-Origin" value="*" /> | |
<add name="Access-Control-Allow-Headers" value="Content-Type" /> | |
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> | |
</customHeaders> | |
</httpProtocol> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there.
I have an Angular Application in one site trying to send http to another server in other site. I tryed this web.config above, on api's side, but didn't work. I'am not sure what happens, I receive the error: "Failed to load https://api.nameofsite.com/system/api/auth/login: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response."
If I add this on web.config:
and to change access-control-allow-headers to:
<add name="Access-Control-Allow-Headers" value="*" />
and remove the line:
<add name="Access-Control-Allow-Origin" value="*" />
Start to work in dev environment (accessing by localhost:4200).
But, if I try to use in production (ng build) also served on IIS. I Receive this error:
POST https://api.nameofsite.com/system/api/auth/login 500
Looking inside request header, the parameters is empty. Something removed the header.
Have you another suggestion of web.config to fix it?
POST https://api.nameofsite.com/system/api/auth/login 500