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

Not working on localhost #2

Open
rja907 opened this issue Apr 17, 2018 · 1 comment
Open

Not working on localhost #2

rja907 opened this issue Apr 17, 2018 · 1 comment

Comments

@rja907
Copy link

rja907 commented Apr 17, 2018

Hi,
I cloned the repo after watching your YouTube video about PWA.
It doesn't work on localhost and just gives a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error.

It was a great video. Thanks for that. :D

@BraggerXYZ
Copy link

This is a common security issue with javascript reading data asynchronosly from different hosts.
In order to make it work you need to set the no-cors header in the fetch request like so:
const res = await fetch('https://newsapi.org/v1/articles?source=t3n&apiKey=${apiKey}',**{mode:'no-cors'}**);

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

2 participants