首页 > 解决方案 > 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');

            });

获取请求正常,但无法发送发布请求

标签: restauthenticationcakephp-3.x

解决方案


推荐阅读