0 votes
in Programming by (400 points)

I am trying to configure node passport oauth2 login.

If call the get url directly from the browswer, everyhting works perfectly.

I am trying to set up the login using react client as frontend.

react axios api call

 const res = await Axios.get(http://locahost:5000/login`)

node.js express

app.use(cors());

app.use(bodyParser.json({ limit: "50mb", extended: true }));

app.get('/npt/login', passport.authenticate('oauth2'));

This is the error I get

Access to XMLHttpRequest at 'https://...' (redirected from 'http://localhost:5000/npt/login') from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Do I need to set the headers in the client app?

Please log in or register to answer this question.

...