"Access-Control-Allow-Origin"标头的值不等于提供的原始错误 [英] The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin error

查看:118
本文介绍了"Access-Control-Allow-Origin"标头的值不等于提供的原始错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

通过' http://127.0.0.1:8000/api/user"(起源)" http://localhost:8080 "已被CORS政策阻止:访问控制-Allow-Origin'标头的值' http://localhost:8080/ *'不等于提供的来源.

Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/user' from origin 'http://localhost:8080' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8080/*' that is not equal to the supplied origin.

我已经创建了中间件,并且没有任何更改:

I have create Middleware and nothing changed:

public function handle($request, Closure $next)
{
    return $next($request)
        ->header('Access-Control-Allow-Origin','http://localhost:8080/*')
        ->header('Access-Control-Allow-Methods','POST,PUT,GET,DELETE,OPTIONS')
        ->header('Access-Control-Allow-Headers','Accept,Authorization,Content-Type')
        ->header('Content-Type','application/json');
}

推荐答案

我不确定,但是chorme不支持 localhost

I am not sure But maybe chorme does not support localhost

尝试使用通配符 * 代替 http://localhost:8080/*

这篇关于"Access-Control-Allow-Origin"标头的值不等于提供的原始错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆