I\'m using:
And after trying to login to my page when using
While you can add Access-Control-Allow-Origin: *
to your server response (in this case IIS) but this is very much advised against.
What's happening here is that your client is http://localhost
and it is trying to access https://mywebsite/api/
which means they're not from the same origin
If you add Access-Control-Allow-Origin: *
you will be allowing the entire world to hit your API endpoint.
I'd suggest making your access control server headers Access-Control-Allow-Origin: *.mysite
and make a vhost for your localhost
to use dev.mysite
or similar.
This will allow your "localhost" to access your API without issues.
You could also add localhost
to a whitelist, but this is also not without its own security implications, and it doesn't work everywhere anyway.
So, in short, make a vhost for your localhost that's in the same domain as your REST service and your issue should be resolved.
Once you go live you should remove the *.mysite
part and use as specific a domain as possible on your whitelist.
Good luck!