Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blocked by cors policy #135

Closed
talwag opened this issue Jun 1, 2020 · 30 comments
Closed

blocked by cors policy #135

talwag opened this issue Jun 1, 2020 · 30 comments

Comments

@talwag
Copy link

talwag commented Jun 1, 2020

Hi
i upload app to github pages and get this error :
(index):1 Access to XMLHttpRequest at 'https://jsonplaceholder.typicode.com/users' from origin 'https://talwag.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
xhr.js:178 GET https://jsonplaceholder.typicode.com/users net::ERR_FAILED

while working with the app local it worked ok
how can i fix it?

@marko-knoebl
Copy link

can confirm ... this happens for me as well if I run the example code from the homepage on any site (the homepage says: "Run this code in a console or from any site:")

fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => console.log(json))

@iamtekson
Copy link

Same error happens for me also

@JSAssassin
Copy link

I am running into the same issue
Here's my error log:

Access to XMLHttpRequest at 'https://jsonplaceholder.typicode.com/posts' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@prokler
Copy link

prokler commented Jun 3, 2020

I am running into the same issue
Here's my error log:

Access to XMLHttpRequest at 'https://jsonplaceholder.typicode.com/posts' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Same here with 'https://jsonplaceholder.typicode.com/todos'

@talwag
Copy link
Author

talwag commented Jun 3, 2020

Now it is working ok although I didn't make any changes, but still the response time is bad.
that also was the case when I worked local, sometimes got cors but most of the time it worked fine.
I guess the server is very unstable.

@typicode
Copy link
Owner

typicode commented Jun 5, 2020

Thanks for the heads up. There were some issues during the past days. It should be fixed now.

@typicode typicode closed this as completed Jun 5, 2020
@justsanjit
Copy link

I am still getting this error.

Capture

@frimmy
Copy link

frimmy commented Jun 19, 2020

Also get the error - might be something to do with the response being returned? This work around has helped me @sanjitkung - calling response.text() and then passing that value to JSON.parse(textRes) ... maybe the server is not returning json atm?

@back2Lobby
Copy link

I am getting same error on this simple fetch request in codepen

fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => console.log(json))

@james-work-account
Copy link

@typicode I'm also getting this error calling the todos uri.

@marko-knoebl
Copy link

can confirm that it has some issues again.

It seems to be working fine if I send a request from the browser while I'm at the site, e.g. when I have https://jsonplaceholder.typicode.com opened in my browser

Also, seems to work fine if I'm at https://google.com ?

@back2Lobby
Copy link

abc

@vincentherail
Copy link

Same error here
Capture d’écran 2021-04-22 à 18 00 48

@seekingperfection
Copy link

@vincentherail Got same error..

@Med1El
Copy link

Med1El commented Apr 22, 2021

same error for me...

@masif1212
Copy link

same error for me

@doriansmiley
Copy link

Same for me

@bhanukumarnew
Copy link

same for me

@doriansmiley
Copy link

doriansmiley commented Apr 23, 2021

This post is irrelevant. It's advocating for installing plugins and using additional services. Go to MDN if you want information on CORS. This article is garbage IMO. I know I can build a proxy as a workaround. What do I need https://jsonplaceholder.typicode.com for if I build my own proxy? The answer is nothing.

A new issue was opened two days ago here. Anyone following this issue should bounce to the new one.

@seekingperfection
Copy link

Currently building a proxy does not solve the problem, unfortunately

@ghost
Copy link

ghost commented Apr 29, 2021

I get this error too.

1 similar comment
@ericsonmoreira
Copy link

I get this error too.

@eyasulegesse
Copy link

try to use the proxy on you browser it works for me now

@Pyrolistical
Copy link

still a problem as of today. no cors headers

$ http HEAD http://jsonplaceholder.typicode.com/posts/1
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Age: 22756
CF-Cache-Status: HIT
CF-RAY: 6e8f6aec89a48419-YVR
Cache-Control: max-age=43200
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Tue, 08 Mar 2022 23:40:44 GMT
Etag: W/"124-yiKdLzqO5gfBrJFrcdJ8Yq0LGnU"
Expires: -1
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Pragma: no-cache
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=T9TReEWsUHvF2EwX9s1kHB9s5I92sgEh%2BaEqu3YUXGKNA1IKksr3FouA6VRZHte9D%2F35c1f3UORskhVBjdFVPiK0dfIplzHi4qCwfHx8aq81Zvg5FGPU99DoeY5fXQJJwfTqWTB78I8FN9Wz25x7"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Vary: Origin, Accept-Encoding
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Powered-By: Express
X-Ratelimit-Limit: 1000
X-Ratelimit-Remaining: 999
X-Ratelimit-Reset: 1645771009
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

@typicode
Copy link
Owner

typicode commented Mar 13, 2022

I can't reproduce the issue. I tried with GET and PUT code examples from https://jsonplaceholder.typicode.com/guide/ in CodePen, JSFiddle and localhost (using the browser console).

Could someone share a failing case on CodePen or any online code editor?

@Pyrolistical
Copy link

@typicode seems to be working again. Your host must have failed and recovered

@Vimbi
Copy link

Vimbi commented Jul 3, 2022

Access to fetch at 'https://jsonplaceholder-typicode-com.translate.goog/users' from origin 'http://localhost:3000' has been blocked by CORS policy: 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.

@thaikolja
Copy link

Also, CORS problem here.

@MosDevx
Copy link

MosDevx commented Jul 23, 2022

Disabling the HTTPS Everywhere extension on my browser worked for me. The response was targeting http://... whilst the extension was causing the page to be https://...

@giolmartin
Copy link

Worked for me at while having the jsonplaceholders page open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests