CORS收割台&x2018;访问控制允许原点’;缺少使用API的json POST

CORS收割台&x2018;访问控制允许原点’;缺少使用API的json POST,cors,laravel-5.8,Cors,Laravel 5.8,在laravel 5.8上安装水果蛋糕/laravel cors 我的testserver使用php artisan serve在127.0.0.1:8000上使用routes/api.php 客户端(nuxt)正在127.0.0.1:3000上运行 我能够使用邮递员工具向服务器发送数据 我已经配置了水果蛋糕/laravel cors protected $middleware = [ // ... \Fruitcake\Cors\HandleCors::class, ]; 和

在laravel 5.8上安装水果蛋糕/laravel cors

我的testserver使用php artisan serve在127.0.0.1:8000上使用routes/api.php 客户端(nuxt)正在127.0.0.1:3000上运行

我能够使用邮递员工具向服务器发送数据

我已经配置了水果蛋糕/laravel cors

protected $middleware = [
    // ...
    \Fruitcake\Cors\HandleCors::class,
];
和config/cors.php

<?php

return [

    /*
     * You can enable CORS for 1 or multiple paths.
     * Example: ['api/*']
     */
    'paths' => [],

    /*
    * Matches the request method. `[*]` allows all methods.
    */
    'allowed_methods' => ['*'],

    /*
     * Matches the request origin. `[*]` allows all origins.
     */
    'allowed_origins' => ['*'],

    /*
     * Matches the request origin with, similar to `Request::is()`
     */
    'allowed_origins_patterns' => [],

    /*
     * Sets the Access-Control-Allow-Headers response header. `[*]` allows all headers.
     */
    'allowed_headers' => ['*'],

    /*
     * Sets the Access-Control-Expose-Headers response header.
     */
    'exposed_headers' => false,

    /*
     * Sets the Access-Control-Max-Age response header.
     */
    'max_age' => false,

    /*
     * Sets the Access-Control-Allow-Credentials header.
     */
    'supports_credentials' => false,
];

“路径”不能为空。您至少应该将其设置为['*',以便覆盖每个请求。

似乎Cors配置正确,但在返回触发消息之前,var_dump()和dd()。不返回任何内容也会导致cors消息

        var_dump($request);
        dd($request);
返回一个json响应(正如我使用json一样)效果很好。(还有其他退货建议吗?)


响应的HTTP状态代码是什么?您可以使用浏览器devtools中的网络窗格进行检查。这是4xx还是5xx错误,而不是200 OK成功响应?请更新配置以定义要在其上运行CORS服务的路径:
'path'=>['api/*']
已报告此问题。这似乎有点复杂。
        return response()->json([
            'data-received' => true
        ]);