突然收到以下警报
跨域读取阻止(CORB)阻止了MIME类型为text / html的跨域响应http://traxit-backend.test/api/register。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768。
无法加载http://traxit-backend.test/api/register:对预检请求的响应未通过访问控制检查:所请求的资源上没有'Access-Control-Allow-Origin'标头。因此,不允许访问来源“ http://localhost:8080”。
选项http://traxit-backend.test/api/register 500(内部服务器错误)
我的配置运行正常,但是今天才开始工作。我不确定我是否需要做点什么。尝试了我在互联网上读到的不同事情,没有运气
kernal.php文件
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Barryvdh\Cors\HandleCors::class,
];
cors.php文件
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedOriginsPatterns' => [],
'allowedHeaders' => ['*'],
'allowedMethods' => ['*'],
'exposedHeaders' => [],
'maxAge' => 0,
];
我在前端使用vuejs和axios。使用laravel护照获取访问令牌。
答案 0 :(得分:0)
添加了'allowedHeaders'=> ['Access-Control-Allow-Origin','*'],
不确定是什么变化,但已解决
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedOriginsPatterns' => [],
'allowedHeaders' => ['Access-Control-Allow-Origin', '*'],
'allowedMethods' => ['*'],
'exposedHeaders' => [],
'maxAge' => 0,
];