跨域请求用CORS头$​​ P $ psent阻止 [英] Cross-Origin Request Blocked with CORS headers present

查看:214
本文介绍了跨域请求用CORS头$​​ P $ psent阻止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器端我有阿帕奇以下过滤器允许所有的方法,并默认所有的来历

on the server side I have the following filter in apache which allow all methods and all origins by defaults

<filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

采用了棱角分明的$ HTTP一个员额的工作,但另一个失败失败。失败在同一个Apache会谈到另一个应用程序的请求。

Using angular $http One post is working, but another fail failed. The request that fails talks to another app on the same apache.

Cross-Origin Request Blocked: The Same Origin Policy disallows 
reading the remote resource at http://localhost:.. 
(Reason: CORS header 'Access-Control-Allow-Origin' 
does not match 'http://localhost:8100, http://localhost:8100').

但响应头确实包含了ACAO

But the response header does contain the ACAO

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
access-control-allow-credentials: true, true
access-control-allow-origin: http://localhost:8100, http://localhost:8100
Vary: Origin
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 22 Oct 2015 04:35:29 GMT

在哪里做了的http://本地主机:8100 ,的 HTTP://本地主机:8100 从何而来?你是否认为这是角$ HTTP或Apache的问题?

Where did the ' http://localhost:8100, http://localhost:8100' come from ? Do you think it is angular $http or Apache problem ?

推荐答案

访问控制允许来源可以接受'*'的为它的价值原点。你不能把一个逗号分隔的列表那里。

Access-Control-Allow-Origin accepts either '*' or a single origin for its value. You can't put a comma-separated list there.

浏览器是匹配的原点(的http://本地主机:8100 的http://本地主机:8100,HTTP://本地主机:8100 并没有得到匹配

The browser is matching the origin (http://localhost:8100 against http://localhost:8100, http://localhost:8100 and not getting a match.

您之前已经上线了类似的问题。它看起来像您运行的是code插入您的CORS头两次。

You have a similar problem on the line before. It looks like you are running the code to insert your CORS headers twice.

这篇关于跨域请求用CORS头$​​ P $ psent阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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