CodingTrain / CodingTrain/Intro-to-Data-APIs-JS
1.1 fetch: Same Origin Policy problem
- Langage dominant
- HTML
- Étoiles
- 759
- Forks
- 592
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Just starting! And already hitting a minor roadblock. Both the code I wrote and the [code from Github](https://github.com/CodingTrain/Intro-to-Data-APIs-JS/blob/source/module1/01_fetch_image/index.html) 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](https://www.npmjs.com/package/live-server), 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?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par l’exemple de fetch 1.1 lié et l’erreur Firefox signalée avec file://, puis comparez-le aux approches avec live-server et Node.js/Express mentionnées dans l’issue. Le travail est considéré comme terminé lorsque la manière prise en charge d’exécuter l’exemple est documentée et que la restriction pertinente du navigateur ainsi que les alternatives sont expliquées.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- express, javascript, node.js
- Domaine
- web-dev
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100