preflight OPTIONS由不铬工作AngularJS要求? [英] Preflight OPTIONS request by AngularJS not working with Chrome?

查看:197
本文介绍了preflight OPTIONS由不铬工作AngularJS要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发使用AngularJS托管这里一个简单的应用程序。我消费我公司开发自己在Laravel的API托管这里。当我尝试登录到使用Firefox的应用,它工作正常。我的API接受pre-航班选择请求,并用200 OK响应。最后,POST请求生成令牌和用户登录

I have developed a simple application using AngularJS hosted here. I am consuming an API I developed myself in Laravel hosted here. When I try to log into the application using Firefox, it works fine. My API accepts the pre-flight OPTIONS request and responds with a 200 OK. Finally the POST request generates a token and the user is logged in.

在另一方面,当Chrome会将pre-航班选择请求时,它收到一个403回,这让我在控制台这个错误:

On the other hand, when Chrome sends the pre-flight OPTIONS request, it receives an 403 back and it gives me this error in the console:

XMLHttpRequest cannot load http://angulairapi.rohanchhabra.in/auth. Invalid HTTP status code 403

我试图发送选项在通过邮差REST客户机/ AUTH请求还,它给回200 OK预期。为什么Chrome的行为也是这样吗?我缺少什么?

I have tried sending the OPTIONS request on /auth via Postman REST client also, and it gives back a 200 OK as expected. Why is Chrome behaving like this? What am I missing?

推荐答案

访问控制是服务器的责任,需要在Laravel配置此。

The Access Control is a server responsibility, you need config this in Laravel.

使用这个包: Laravel一个Cors 这可以帮助很多。

Use this package: Laravel Cors this helps very much.

这篇关于preflight OPTIONS由不铬工作AngularJS要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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