I'm trying for days now to send a valid redirect request in my App. What should happen: If I try to perform an action that requires me to be logged in, my express app should redirect to the login URL.
router.use(function(req,res,next){
if(req.session.user == null){
res.redirect('http://localhost:4200/#/login');
}
else
next();
});
My CORS implementation:
var corsOptions = {
origin: process.env.ctxCliente,
credentials: true
}
app.use(cors(corsOptions));
The error:
XMLHttpRequest cannot load http://localhost:4200/#/login. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'null' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
On my Angular App I'm sending {withCredentials: true} with all requests, because I need to use a cookie to verify the user session id
Access-Control-Allow-Origin
response to the preflight request in such a case, than just*
. – CBroeorigin: true
incorsOptions
– sideshowbarker