Cross domain requests using Angular & NodeJs (CORS)

0

I am trying to do cross-domain requests (GET, POST, DELETE...) with Angular and NodeJs via CORS. I am successful when I try on Chrome browser but on IE11 on Win7 I get errors below.

SEC7118: XMLHttpRequest for http://master.domain:1300/login required Cross-Origin Resource Sharing (CORS).

SEC7119: XMLHttpRequest for http://master.domain:1300/login required CORS preflight.

SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.

Master domain side I set header Access-Control-Allow-Origin so successfully working on Chrome.

I have tried xdomain library but I could not succeed with Angular. I may miss something but I do not know what. There is no example on the internet.

What can I do to work this on IE? I can use any other way except CORS.

Any help?

Thanks

javascript
node.js
angular
cors
cross-domain
asked on Stack Overflow Mar 2, 2017 by baris usanmaz • edited Dec 24, 2018 by Al-Mothafar

1 Answer

1

Just setting "Access-Control-Allow-Origin" header might not be enough, dependent on the type of request you're making. You should also set the "Access-Control-Allow-Methods" and "Access-Control-Allow-Headers"

As an example:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS
Access-Control-Allow-Headers: Content-Type
answered on Stack Overflow Mar 2, 2017 by MikeOne

User contributions licensed under CC BY-SA 3.0