DEV Community

Cover image for how can i fix this issue
Ayoub
Ayoub

Posted on

how can i fix this issue

Image description

Top comments (11)

Collapse
 
adev03 profile image
Ayoub

thanks guys , i found that the problem is firefox is causing that problem cuz off security

Collapse
 
brentdalling profile image
Brent Dalling

I would use some caution with this. I develop using Firefox and I have never run into this problem just due to the browser. Usually this is a config item with the request or the API server. In this case my codepen rules out the API. Meaning this is a configuration issue with your code.

Even if the config item is only broken in Firefox you should fix it. Failure to do so will result in Firefox users not being able to use the resource you are building. Furthermore, leaving this issue will likely result in more bugs or instability in the future.

Collapse
 
posandu profile image
Posandu

Try replacing https://localhost:3000 with http://localhost:3000 (the 's' got removed) in your code.

Collapse
 
brentdalling profile image
Brent Dalling

So this is a CORS error. Here is a link for more information. auth0.com/blog/cors-tutorial-a-gui...

But here is the GIST of it. CORS is a way that we protect our resources by limiting consumers of the resources to the same domain. Usually we see this error when you're writing a new API or connecting up to an API. Essentially, domain a hosting your site can't talk to domain b until the CORS policy is set correctly.

Collapse
 
brentdalling profile image
Brent Dalling

I can see that you are using a publicly available API. I'm not sure what is wrong with your code. But, I created a simple codepen to give you an idea on how it is meant to be consumed.

codepen.io/brentvdalling/pen/LYdKP...

Collapse
 
adev03 profile image
Ayoub

yes with copen the code work but in localhost not

Collapse
 
pleasebcool profile image
pleaseBcool • Edited

Hmm can you give us more info? Are you using node js?
What are you trying to do?

Collapse
 
adev03 profile image
Ayoub

i am using react js

Collapse
 
pleasebcool profile image
pleaseBcool

and what are you trying to do?

Collapse
 
adityakrcodes profile image
Aditya Kumar • Edited

Are you connected to the internet?

Collapse
 
adev03 profile image
Ayoub

yes of cours