【发布时间】:2019-08-20 05:19:59
【问题描述】:
当我从 Angular 应用程序向 Laravel 发送调用时,我遇到了以下问题
从 'http://localhost:8083/api/login_otp' 访问 XMLHttpRequest 来源 'http://localhost:4200' 已被 CORS 策略阻止: Access-Control-Allow-Headers 不允许请求标头字段 ip 在预检响应中。
我找到了解决方案,并在 CROS.php 中进行了以下更改
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, DELETE, OPTIONS')
->header('Access-Control-Allow-Headers', 'Origin, Content-Type, X-Auth-Token, Authorization, X-Requested-With, x-xsrf-token');
}
我在 Access-Control-Allow-Headers 中添加了 x-xsrf-token,但我仍然遇到同样的错误。
【问题讨论】:
标签: php angular laravel-5 cross-origin-read-blocking