Closed halfrubbish closed 7 years ago
Hi @mattpacker,
Can you show me the Invoke-WebRequest you're doing? are you adding the Host header with your domain when you invoke the request?
Also, are you sure your json request is coming from http://mydomain.com and not from any subdomain (like for example http://www.mydomain.com) ? The host header will have to exactly match what you pass into AddAllowedOrigin.
I tested this scenario and the headers do get added. I think @Jark raised the possible problem. A simple test for you @mattpacker would be to use the EnableCors()
method, without explicitly specifying the host. That should work.
@mattpacker I created a reproduction scenario with Chrome and got the same error message, I'm investigating it right now.
@tomkuijsten thanks for investigating.
Make sure you use fiddler to examine the responses and not chrome itself. Chrome will sometimes leave out some of the headers / remove headers that you specify in your JavaScript.
Well chrome did it perfectly well, the problem was that I made the exact same mistake as @mattpacker probably. I didn't use the EnableCors()
but specified a wrong host. When I fixed that it all worked fine, tested in Chrome (developer tools are not that clear about the problem though, you should check the console for the real error).
@mattpacker, please, confirm that it was the hostname, or else add another reproduction scenario.
Hmm. I am still having issues here. Is it possible I can supply you with the hostname / IP address to your email to avoid pasting here and you can take a look?
Thank you for your help.
Send me an e-mail: tomkuijsten at gmail.com
Didn't receive anything yet. We're using CORS internally here and have no problem at all. I'm gonna close this issue, if you send me some reproduction scenario we can reopen it.
I have the following code which is to act as a json proxy between two bits of my network but the CORS header doesn't seem to be being added on. Chrome complains and I also can't see the header if I just do a normal powershell invoke-webrequest on it.
Any ideas why?
`
`