gpt4 book ai didi

javascript - 收到错误请求的资源上不存在 'Access-Control-Allow-Origin' header

转载 作者:行者123 更新时间:2023-11-30 21:03:21 25 4
gpt4 key购买 nike

我正在尝试创建一个 headless 的 drupal 应用程序。我正在使用 drupal 8 作为后端并作为前端使用react。我使用核心休息服务模块在 drupal 8 中创建了 REST 服务。问题是当我调用 api 时它给我错误,即

Fetch API cannot load http://192.168.1.246/headless-react/api/events. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

我为 cors.config 配置了 services.yml 文件,但仍然出现错误。谁能知道如何解决它?谢谢

最佳答案

安装 CORS 模块 https://www.drupal.org/project/cors

它将允许您克服与交叉源相关的错误

关于javascript - 收到错误请求的资源上不存在 'Access-Control-Allow-Origin' header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46888824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com