-1

For an Angular 10 application that I am running, I am getting the following error when the page loads in Safari. (working fine for Chrome and Firefox).

Origin http://localhost:8080 is not allowed by Access-Control_origin

CORS Error

I have tried the following solutions to resolve this. But none of them seems to work.

  1. In server.ts I am setting the headers as follows:-
app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});
  1. I have also tried the follows:-
app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
  next();
});
  1. I have also tried this, by clearing browser cache and cookies.

None of these seems to work. Can any one help me with this?

  1. List item
  • You could use this [example here](https://stackoverflow.com/a/63041247/11644167). It will solve your problem! – Willian Jul 23 '20 at 14:35

1 Answers1

-1

From that answer it seems, that adding Accept-Language inside Access-Control-Allow-Headers should resolve the problem.

J. T.
  • 1
  • 2
  • I tried this. ```res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept-Language, Accept"); ``` It doesn't seem to work. :( – Pratik Mukherjee Jul 23 '20 at 17:58