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

1.1 fetch: Same Origin Policy problem #43

Open
berndbausch opened this issue Aug 20, 2019 · 2 comments
Open

1.1 fetch: Same Origin Policy problem #43

berndbausch opened this issue Aug 20, 2019 · 2 comments

Comments

@berndbausch
Copy link

berndbausch commented Aug 20, 2019

Just starting! And already hitting a minor roadblock. Both the code I wrote and the code from Github lead to an error in my browser when it tries to fetch the image:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/bbausch/js-working-with-data/1.1-fetch/rainbow.jpg

This is Firefox 68 on Xubuntu. I solved the problem by hosting the picture on a web server (the node.js/express.js web server from video 2.1 :)), but I wonder why I am the only one with this problem?

EDIT: Dan uses live-server, and on its web site, I read

AJAX requests don't work with the file:// protocol due to security restrictions, i.e. you need a server if your site fetches content through JavaScript.

So I feel validated! But my question remains - is everybody using live-server or are there other methods to get around cross-origin problems?

@tamtoronto
Copy link

Anyone solve this problem?

@anuraghazra
Copy link

Not necessarily live-server, but you need a server/localserver to do AJAX requests.. otherwise it will throw.
It is easy to work with live-server, but there are other alternatives too, like http-server https://github.com/http-party/http-server

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

3 participants