You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CodeIgniter 4.4.1中CurlRequest始终返回{"CSP":{}}问题求助

CodeIgniter 4.4.1 CurlRequest 固定返回 {"CSP":{}} 问题

问题现象

  • 使用CodeIgniter 4.4.1框架,通过CurlRequest发起任意请求(外部或内部端点),返回结果始终为{"CSP":{}}
  • 已在配置中设置public bool $CSPEnabled = false禁用CSP,问题仍未解决

复现代码

亚马逊令牌交换请求

// 省略部分字段
$lwa_auth = [ 
    'grant_type' => 'authorization_code',
    'code' => $spapi_oauth_code 
];
$curl = \Config\Services::curlrequest();
$response = $curl->request( 'POST', 'https://api.amazon.com/auth/o2/token', [
    'form_params' => $lwa_auth
] );

本地测试端点

class AuthTest extends ResourceController
{
    public function index()
    {
        $data = [
            'grant_type' => $this->request->getVar('grant_type'),
            'code' => $this->request->getVar('code'),
            'redirect_uri' => $this->request->getVar('redirect_uri'),
            'client_id' => $this->request->getVar('client_id'),
            'client_secret' => $this->request->getVar('client_secret')
        ];
        log_message('debug', 'Auth Test Data: ' . json_encode( $data ) );
        return $this->response->setJSON( [ 'status' => 'success' ] );
    }
}

测试验证

  • 将Curl请求指向本地测试端点时,后端日志能正常接收请求数据,但返回结果依旧是{"CSP":{}}
  • 使用Postman调用本地测试端点和亚马逊令牌端点,均可获取正确响应

内容的提问来源于stack exchange,提问作者Craig Jacobs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 11:02:23