Cross domain requests using Angular & NodeJs (CORS)


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?


asked on Stack Overflow Mar 2, 2017 by baris usanmaz • edited Dec 24, 2018 by Al-Mothafar

2 Answers


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

Just try this code in nodejs side it's working

app.use(function (req, res, next) {
  res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200');
  res.setHeader('Access-Control-Allow-Methods', 'POST');
  res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
  res.setHeader('Access-Control-Allow-Credentials', true);
answered on Stack Overflow Jun 22, 2019 by Harsh Patel

User contributions licensed under CC BY-SA 3.0