Reputation: 669
When im going to my server (http://localhost/auth/twitch) it works fine. I am redirected to the twitch login, but when i use my react app calling with axios my backend the address, it doesn't work and i got this:
Access to XMLHttpRequest at 'https://www.twitch.tv/login?client_id=*&redirect_params=client_id%3Dese8nc3f4xsmha7gqzaba1b4m4arro%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8000%252Fauth%252Ftwitch%252Fcallback%26response_type%3Dcode%26scope%3Duser_read' (redirected from 'http://localhost:8000/auth/twitch') from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
What am I doing wrong ?
I'm using passport-twitch-new.
Here is the code :
app.get("/auth/twitch", passport.authenticate("twitch"), (req, res) => {});
app.get("/auth/twitch/callback", passport.authenticate("twitch"), (req: any, res: any) => {
res.redirect("http://localhost:3000/success");
});
I tried to use cors with origin * it doesn't change anything
Upvotes: 0
Views: 208
Reputation: 11
Have you tried using the following?
app.enable('trust proxy')
Also under app.use, add cookie: {sameSite: "none", secure: true}
Lastly, change back your origin to your localhost.
Let me know if it works
Upvotes: 1