php - Lumen API 响应在标头中返回错误的“内容类型”。仅在 Serverpilot/DigitalOcean 上
问题描述
我正在通过 DigitalOcean 上的 Serverpilot 运行我的生产和测试服务器。
我的最后一个 API 是用 Laravel 的 Lumen 编写的。我以前用过几次,从来没有遇到过这个问题。
顺便说一句,在我的本地环境中一切正常。(OS X。代客)
该应用程序是一个 API,它从 Webflows API 收集数据,将其存储在本地数据库中,并将其返回给调用 API 的方式。(为什么?我们需要针对不同的 CMS 进行格式化,而 Webflow 对请求有限制)
返回看起来像这样
return ResponseService::getResponse('success', $items, 200);
服务看起来像这样
public static function getResponse(string $status, iterable $payload, int $http_code)
{
return response()->json(
[
'status' => $status,
'payload' => $payload
],
$http_code,
[
'Content-type' => 'application/json'
]
);
}
...并且$items
是对数据库的标准调用,雄辩$items = $site->collections()->where('_id', $collection_id)->first()->items()->metas($request->data)->paginate();
在 Postman 中运行请求时,我在标题中得到Content-type: text/html; charset=UTF-8
. 如前所述,这仅在测试和生产服务器上。不在本地环境中。
我在这里做错了什么?
解决方案
推荐阅读
- python - 覆盖 - PermissionError:[Errno 1] 不允许操作
- swift - Testflight 崩溃报告未出现在 xcode 中
- html - 自动共享等宽的非表格布局固定解决方案?
- php - 有没有办法让我从 MySQL DB 中获取数据并将其显示在引导表中?
- php - 软件包 willvincent/laravel-rateable 无法在 laravel 8 上安装
- python - Keras 模型的自定义损失函数给出不正确的答案
- javascript - 以下哪一项是在 ReactJS 中编写“获取”自定义钩子的更好模式
- oracle-sqldeveloper - Cognos 文本框提示:Oracle Invalid number 错误
- javascript - 使用 React 我的 img src 出现问题
- sql - 将sql行转换为单行多列数据