CodingTrain / CodingTrain/Intro-to-Data-APIs-JS
1.1 fetch: Same Origin Policy problem
- Lenguaje dominante
- HTML
- Estrellas
- 759
- Forks
- 592
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con el ejemplo de fetch 1.1 enlazado y el error de Firefox con file:// informado, y compáralo después con los enfoques de live-server y Node.js/Express mencionados en el issue. Se considera terminado cuando se documente la forma compatible de ejecutar el ejemplo y se expliquen la restricción relevante del navegador y las alternativas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- express, javascript, node.js
- Área
- web-dev
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100