2013-08-04 123 views
1

为什么我的网址已经在Access-Control-Allow-Origin的头部了!访问控制 - 允许 - 来源不允许

错误

XMLHttpRequest cannot load http://cdn.localhost/data/voucher/16_ead32751b66fd6c7856b7db0e186574df37a7d08.pdf. Origin http://secure.localhost is not allowed by Access-Control-Allow-Origin. 
Refused to get unsafe header "Accept-Ranges" 

htaccess的(cdn.localhost)

Header add Access-Control-Allow-Origin "http://secure.localhost" 
+0

你有权访问服务器'dyntest.dk'或在那里做了任何更改? – Salman

+0

这两个域都是我的 – clarkk

+0

如果我理解正确,你是从一个不同的域做XMLHTTPRequest。您需要修改您的服务器端脚本以允许跨域请求。 – Salman

回答

2

也可以尝试从this post发送以下标题:

// Specify domains from which requests are allowed 
header('Access-Control-Allow-Origin: *'); 

// Specify which request methods are allowed 
header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); 

// Additional headers which may be sent along with the CORS request 
// The X-Requested-With header allows jQuery requests to go through 
header('Access-Control-Allow-Headers: X-Requested-With'); 

// Set the age to 1 day to improve speed/caching. 
header('Access-Control-Max-Age: 86400'); 
+1

你怎么知道他使用的是PHP? – Salman

0

为规范访问控制 - 允许 - Origin谈到空格分隔的URL语法。也许第二次出现的头部会覆盖客户端中的第一个 - 在单个头部中尝试多值版本。

+0

你是什么意思'多值'..你能举个例子吗? :) – clarkk

+0

不知道如何包装会看起来,但一行不引号: Access-Control-Allow-Origin:http://secure.dyntest.dk http://secure.localhost – covener

相关问题