“Access-Control-Allow-Origin"标头的值不等于提供的原点错误 [英] The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin error
本文介绍了“Access-Control-Allow-Origin"标头的值不等于提供的原点错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到此错误:
在http://127.0.0.1:8000/api/user' from origin 'http://localhost:8080' 已被 CORS 策略阻止:'Access-Control-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/*
Try wildcard *
Instead of http://localhost:8080/*
这篇关于“Access-Control-Allow-Origin"标头的值不等于提供的原点错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文