javascript - CORS Error with Ngrok and Express Server: "No 'Access-Control-Allow-Origin' header is pres

I'm developing a React application that uses Firebase Authentication for Google sign-in. After suc

I'm developing a React application that uses Firebase Authentication for Google sign-in. After successful sign-in, I retrieve the Firebase ID token and send it to my Node.js/Express server for verification.

When I attempt to sign in using Google, I encounter the following errors in my browser's console:

Access to XMLHttpRequest at 'http://localhost:3005/api/verify-token' from origin '' 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.


SignUp.jsx:39 Error during sign-in: AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}

POST http://localhost:3005/api/verify-token net::ERR_FAILED

My React application is running through ngrok at , and my Express server is running on http://localhost:3005.

My React application is running through ngrok at , and my Express server is running on http://localhost:3005.

What I've Tried:

  • I've added the cors middleware to my Express server, specifying the ngrok URL as the allowed origin.

  • I've verified that the Firebase Admin SDK is correctly initialized on the server.

  • I've made sure that the Authorization header is being sent from the react app.

  • I've verified the token verification logic on the server side. My Question:

Why am I still getting the CORS error and the network error? Is there something wrong with my CORS configuration, or is there another issue that I'm overlooking? How do I properly configure my Express server to allow cross-origin requests from my ngrok URL?

Any help would be greatly appreciated.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744306279a4567728.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信