I get this error:
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');
}
I am not sure But maybe chorme does not support localhost
Try wildcard *
Instead of http://localhost:8080/*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.