gpt4 book ai didi

javascript - CI 和 Angular4 : Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response

转载 作者:行者123 更新时间:2023-11-28 04:02:42 24 4
gpt4 key购买 nike

我已将所有这些加载到我的后端 (CI) 上,并将其放置在构造上:

    header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');

$method = $_SERVER['REQUEST_METHOD'];
if($method == "OPTIONS") {
die();
}

但我仍然有这个错误:

Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

这个问题是来自后端(CI)还是我的前端(Angular4)?

最佳答案

您需要在后端的响应中添加 Access-Control-Allow-Headers header ,就像您对请求所做的那样

关于javascript - CI 和 Angular4 : Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46966349/

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