jaredhanson/passport-twitter

Work with CORS

JuliaAlaeva opened this issue · 1 comments

I have a server node.js with passport social auth.
But I have problem with CORS. Browser block my query, if
res.header('Access-Control-Allow-Origin', "*");
But if I set
res.header('Access-Control-Allow-Origin', "http://localhost:4200");
My callback doesn't work.
What is solve?
I use:
app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', "http://localhost:4200"); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type, AUTHORIZATION, X-CLIENT-ID, X-CLIENT_SECRET'); res.header('Access-Control-Allow-Credentials', 'true'); res.header('Access-Control-Max-Age', '120000'); if ('OPTIONS' === req.method) { res.status(200).send('ok'); } else { next(null, req, res); } });

Problem solve with change callback.