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
I have tried the following solutions to resolve this. But none of them seems to work.
- 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();
});
- 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();
});
- I have also tried this, by clearing browser cache and cookies.
None of these seems to work. Can any one help me with this?
- List item