Networkerror when attempting to fetch resource перевод

Когда я использую aurelia-fetch-client для отправки данных json на сервер, я получаю эту ошибку «TypeError: NetworkError при попытке извлечь ресурс». Я думаю, что ваш ответ очень полезен для меня.

Вероятно, это связано с распределением ресурсов между источниками (CORS).

Механизм общего доступа к ресурсам между источниками (CORS) предоставляет веб-серверам средства управления междоменным доступом, которые обеспечивают безопасную междоменную передачу данных. Современные браузеры используют CORS в контейнере API — таком как XMLHttpRequest или Fetch — для снижения рисков HTTP-запросов между источниками. (Источник: https://developer. mozilla. org/en-US/docs/Web/HTTP/Access_control_CORS

Если у вас есть Chrome, вы можете попробовать запустить в Windows команду: chrome. exe —user-data-dir="C:/Chrome dev session" —disable-web-security и посмотреть, сможете ли вы запустить свой код в эта среда. Это позволит получить доступ к запросам заголовка «access-control-allow-origin».

Я попытался запустить части вашего кода нормально в Chrome, Firefox и Edge и получил те же ошибки CORS. Однако он запустился, когда я использовал вышеуказанную команду. Вы не дали слишком много информации для продолжения, но вам, возможно, придется внести некоторые изменения на стороне сервера, а также в своем коде.

Приведенная выше команда и более полезная информация о CORS можно найти здесь, в SO: «В запрашиваемом ресурсе отсутствует заголовок« Access-Control-Allow-Origin »»

Надеюсь, это может, по крайней мере, указать вам правильное направление.

Я чувствую, что это не может быть связано с CORS. Возможно, он имеет дело с механизмом «импорта» (?). Вот мой случай: я получил сообщение «Ошибка карты источника», когда я только что обновил свою локальную версию OpenLayers до v5.0.0. Вот мой HTML:

и сообщение об ошибке:

Удивительно, но код JavaScript работает правильно, и карта корректно отображается на экране, даже до того, как на консоли появилось сообщение «Ошибка карты источника».

Если я вернусь к предыдущей версии OpenLayers, разница только в следующем:

это работает также, но без сообщения об ошибке.

Я не знаю, в чем винить, но оригинальный вопрос из «Суреша» также имеет отношение к механизму «импорта». В моем случае я не вижу смысла с CORS.

I’ve found a lot of question similar to my problem but I don’t get solution that’s why I’ve asked here.

I’ve just started learning front end development using React. I’ve made separate app for front end and backend running at different ports.

Backend : Laravel framework app running at incomeexpense. stacklearning. com/

Frontend : React app running at localhost:3000/

I’ve a form like this:

I’ve following routes,

Here is CORS middleware,

Finally here is user creating function

When I send the post request from react app following error is shown at console

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://incomeexpense. stacklearning. com/api/users. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

TypeError: "NetworkError when attempting to fetch resource." Register. js:39 Cross-Origin Request Blocked:

The Same Origin Policy disallows reading the remote resource at https://incomeexpense. stacklearning. com/api/users. (Reason: CORS request did not succeed).

I know this error is due to different domain and browser prevent resource access to different domain.

I just want to know what I need need to do at front and at back end to make things right

PS: back end code works perfectly while sending request from postman.

On this Page

Source maps are JSON files providing a way to associate transformed sources, as seen by the browser, with their original sources, as written by the developer. You can sometimes encounter problems working with source maps. This page explains the most common problems and how to fix them.

Note: If you’re new to source maps, you can learn more about them in How to use a source map.

General source map error reporting

If you do see a problem, a message will appear in the webconsole. This message will show an error message, the resource URL, and the source map URL:

Here, the resource URL tells us that bundle. js mentions a source map, and the source map URL tells us where to find the source map data (in this case, relative to the resource). The error tells us that the source map is not JSON data — so we’re serving the wrong file.

There are a few common ways that source maps can go wrong; they are detailed in the following sections.

Source map missing or inaccessible

The source map resource can be missing or inaccessible.

The fix here is to make sure the file is being served and is accessible to the browser

Invalid source map

The source map data can be invalid — either simply not a JSON file at all, or with an incorrect structure. Typical error messages here are:

Original source missing

An original source may be missing. You may encounter this when trying to open one of the original sources in the debugger. The message looks a little different in this case:

In this case, the error will also be displayed in the source tab in the debugger:

NetworkError when attempting to fetch resource

A bug in Firefox prevents it from loading source maps for web extensions.

Источники:

https://teh-fed. ru/networkerror-when-attempting-to-fetch-resource/

Понравилась статья? Поделиться с друзьями:
Добавить комментарий

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: