Я построил бэк-энд для приложения для списка, используя Laravel. Сейчас я пытаюсь построить фронт-энд для него, используя React. Когда я пытаюсь отправить запрос сообщения (для добавления новой задачи) в API, я получаю следующую ошибку Cors. < /P>
Access to fetch at 'http://localhost:5173/' (redirected from 'http://localhost:8000/api/tasks') from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Я спросил чат GPT, и он сказал мне установить пакет Fruitcake/Laravel-Cors. Однако, когда я пытаюсь запустить команду в моем терминале, я получаю следующую ошибку: < /p>
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires fruitcake/laravel-cors ^2.0 -> satisfiable by fruitcake/laravel-cors[v2.0.0, ..., v2.2.0].
- fruitcake/laravel-cors[v2.0.0, ..., v2.0.1] require illuminate/support ^5.6|^6.0|^7.0|^8.0 -> found illuminate/
support[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
- fruitcake/laravel-cors v2.0.2 requires illuminate/support ^6|^7|^8 -> found illuminate/support[v6.0.0, ..., v6.
20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
- fruitcake/laravel-cors[v2.0.3, ..., v2.2.0] require illuminate/support ^6|^7|^8|^9 -> found illuminate/support[
v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16] but these were not loaded, likely because it conflicts with another require.
, пожалуйста, кто -нибудь может сказать мне, как я исправляю эту ошибку Cors?
Я построил бэк-энд для приложения для списка, используя Laravel. Сейчас я пытаюсь построить фронт-энд для него, используя React. Когда я пытаюсь отправить запрос сообщения (для добавления новой задачи) в API, я получаю следующую ошибку Cors. < /P> [code]Access to fetch at 'http://localhost:5173/' (redirected from 'http://localhost:8000/api/tasks') from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.[/code] Я спросил чат GPT, и он сказал мне установить пакет Fruitcake/Laravel-Cors. Однако, когда я пытаюсь запустить команду в моем терминале, я получаю следующую ошибку: < /p> [code]Your requirements could not be resolved to an installable set of packages.
Problem 1 - Root composer.json requires fruitcake/laravel-cors ^2.0 -> satisfiable by fruitcake/laravel-cors[v2.0.0, ..., v2.2.0]. - fruitcake/laravel-cors[v2.0.0, ..., v2.0.1] require illuminate/support ^5.6|^6.0|^7.0|^8.0 -> found illuminate/ support[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require. - fruitcake/laravel-cors v2.0.2 requires illuminate/support ^6|^7|^8 -> found illuminate/support[v6.0.0, ..., v6. 20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require. - fruitcake/laravel-cors[v2.0.3, ..., v2.2.0] require illuminate/support ^6|^7|^8|^9 -> found illuminate/support[ v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16] but these were not loaded, likely because it conflicts with another require.
[/code] , пожалуйста, кто -нибудь может сказать мне, как я исправляю эту ошибку Cors?