Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 即使启用CORS也无法发出请求?_Angularjs_Laravel 4_Cors_Same Origin Policy - Fatal编程技术网

Angularjs 即使启用CORS也无法发出请求?

Angularjs 即使启用CORS也无法发出请求?,angularjs,laravel-4,cors,same-origin-policy,Angularjs,Laravel 4,Cors,Same Origin Policy,我正在尝试调用一个内置于Laravel的APIhttp://localhost:8000 从位于的AngularJS应用程序http://localhost. 我得到一个错误,说: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/auth. This can be fixed by moving the resou

我正在尝试调用一个内置于Laravel的APIhttp://localhost:8000 从位于的AngularJS应用程序http://localhost. 我得到一个错误,说:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/auth. This can be fixed by moving the resource to the same domain or enabling CORS.
我在网站上发送了一个选项请求http://localhost:8000 通过邮递员,以下是回复:

Access-Control-Allow-Credentials → true
Access-Control-Allow-Headers → X-Requested-With, Content-Type, X-Auth-Token, Origin, Authorization
Access-Control-Allow-Methods → POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin → *, chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Cache-Control → no-cache
Connection → close
Content-Type → text/html; charset=UTF-8
Date → Mon, 29 Dec 2014 06:33:26 GMT
Host → localhost:8000
Vary → Origin
X-Powered-By → PHP/5.5.9-1ubuntu4.5

从我所看到的,所有的方法都是允许从所有的来源。我不明白为什么这行不通。我缺少什么?

您还需要对$httpProvider进行一些更改


您使用哪个服务器和版本进行部署?我想我使用的是用于测试的PHP服务器。我只是运行了php artisan serve,它启动了服务器上的应用程序http://localhost:8000Instead 如果试图修复此临时问题,请从rest服务器提供静态页面,或者使用Web服务器将两个连接代理到一个主机中