Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CORS error when making a request to /authorize

Hello, I hope you can guide me in the right direction here since I've been pretty stuck. I am making a request from my react from end to my nodejs api and I am getting the following error. Any idea what's happening? Thanks!

 

Access to fetch at 'https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=22C384&scope=activity%20heartra...' (redirected from 'http://localhost:5000/api/fitbit/authorize') from origin 'http://localhost:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Best Answer
0 Votes
3 REPLIES 3

Hi @alvarodltlp,

 

Welcome to the forums!

 

Are you attempting to authorize other users other than yourself? Or are you using this authorization URL for yourself for testing purposes? The reason I ask is the redirect URI you're using is fine for testing purposes, but wont work in a production environment. Localhost is not a URL that is external to the internet world that the public can access. You'll need to provide a valid redirect URI to your application to redirect your users back to after they grant consent to your application.

 

I hope this helps. Let me know if you continue to encounter this error after changing your redirect URI.

Best Answer
0 Votes

I am facing the same cors issue and hasn't figure it out how to solve this.

 

Best Answer
0 Votes

@sajid Welcome to the forums!

Are you using localhost as your redirect url as well? Or are you using your IP address?

Best Answer
0 Votes