Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
Javascript 科尔斯奇怪的行为_Javascript_Angular_Cors - Fatal编程技术网

Javascript 科尔斯奇怪的行为

Javascript 科尔斯奇怪的行为,javascript,angular,cors,Javascript,Angular,Cors,我正在使用axios客户端和angular2向特定端点进行RESTFull post 我得到这个CORS错误: 加载失败http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute: 请求的资源上不存在“Access Control Allow Origin”标头。起源'http://localhost:4200因此,不允许访问。 当我在chrome开发工具网络选项卡中检查飞行前请求时,一切似乎都正

我正在使用axios客户端和angular2向特定端点进行RESTFull post

我得到这个CORS错误:

加载失败http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute: 请求的资源上不存在“Access Control Allow Origin”标头。起源'http://localhost:4200因此,不允许访问。

当我在chrome开发工具网络选项卡中检查飞行前请求时,一切似乎都正常。“网络”选项卡显示以下内容:

Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:OPTIONS
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
ACCESS-CONTROL-ALLOW-CREDENTIALS:true
ACCESS-CONTROL-ALLOW-HEADERS:authorization,content-type
ACCESS-CONTROL-ALLOW-METHODS:POST
ACCESS-CONTROL-ALLOW-ORIGIN:http://localhost:4200
ALLOW:POST,OPTIONS
下面是实际的帖子:

 Request URL:http://localhost:57772/api/deepsee/v1/bi_cube_updated_namespace/Data/KPIExecute
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:57772
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
CACHE-CONTROL:no-cache
Connection:Keep-Alive
CONTENT-LENGTH:179
Content-Type:application/json; charset=utf-8
Date:Tue, 14 Nov 2017 12:53:46 GMT
EXPIRES:Thu, 29 Oct 1998 17:04:19 GMT
Keep-Alive:timeout=120
PRAGMA:no-cache
Server:Apache

听起来您只是在
选项
响应中包含响应标题,而不是
发布
响应。您需要在两个响应中都包含它们。

如果您的api
url
不正确,您可能也会看到
CORS
问题。确保他们都好,他们都好。我甚至在chome dev network tab.Ok中将reponse paylaod视为json。后端是什么?是的,我正在尝试设置它们。