rest - CakePHP 3 REST API ajax 登录解决方案
问题描述
有什么解决办法吗?我正在尝试在 CakePHP 3 中制作 REST API。在中间件中
->add(new CsrfProtectionMiddleware([
'httpOnly' => true
]))
->add(function($request, $response, $next) {
return $next($request, $response)
->withHeader('Access-Control-Allow-Origin', '*')
->withHeader('Access-Control-Allow-Methods','*')
->withHeader('Access-Control-Allow-Credentials', true)
->withHeader('Access-Control-Allow-Headers', '*')
->withHeader('Access-Control-Allow-Type', 'application/json');
});
获取请求正常,但无法发送发布请求
解决方案
推荐阅读
- windows - 重写运行批处理文件
- php - 使用 PHP 会话从数据库中获取文件
- python - “ImportError:导入 mariadb 时 DLL 加载失败:找不到指定的模块”的解决方法。
- php - GULP 4 - 使用 browsersync 和 PHP 提示下载
- javascript - 从数据库中获取对象数组并用反应显示它
- javascript - 新编译的 React 应用程序符合预期,后续运行表现出意外行为
- python - 如何让 Xlsxwriter 默认激活 Excel 工作表中的标题?
- python - 如何逐一比较分组中的字符串值
- xaml - Visual Studio 2019,XAML 这些属性符号是什么?
- reactjs - 是否可以暂停代码直到解决承诺?