everything works fine if i type the url with http://localhost:8000/auth/twitch, I got redirected.
app.get("/auth/twitch", passport.authenticate("twitch"), (req, res) => {
console.log("mdr")
});
app.get("/auth/twitch/callback", passport.authenticate("twitch"), (req, res) => {
const { id, email, display_name, created_at, login, profile_image_url } = req.user;
const date = new Date(created_at);
return res.redirect(`http://localhost:3000/success?id=${id}&email=${email}&pseudo=${display_name}&channel=${login}&date=${date.toLocaleDateString("fr")}&avatar=${profile_image_url}}`);
});
But if make a call from the frontend reactjs with this
axios.get(`http://localhost:8000/auth/twitch`);
I got this message :
Access to XMLHttpRequest at 'https://www.twitch.tv/login?client_id=*******&redirect_params=client_id%3Dl558bbzlgzb5n41ggxc4901xhkhv5g%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.
I've set cors this way in the back end :
app.use(cors({
origin: "*",
methods: "GET, POST, DELETE, PUT",
credentials: true,
}));
But it doesn't change anything.
What am I missing?
Thanks