我正在尝试使用Google Drive Web APIs在我的网站上创建“保存到驱动器”按钮,但没有结果。点击按钮后会出现如下错误:
*XMLHttpRequest cannot load http://myFILEsiteONE/file.doc. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myMAINsiteTWO' is therefore not allowed access.*
在stackoverflow上有很多关于此问题的答案:所有问题都通过标题解决,在谷歌文档中有描述。
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Range
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range
但我的网站已有此标题。有get_headers
php函数的结果:
array{
['0'] => string'HTTP/1.1 200 OK'
['1'] => string'Server: nginx'
['2'] => string'Date: Tue, 23 Dec 2014 13:41:52 GMT'
['3'] => string'Content-Type: text/html; charset=UTF-8'
['4'] => string'Content-Length: 1643'
['5'] => string'Connection: close'
['6'] => string'Vary: Accept-Encoding'
['7'] => string'X-Powered-By: PHP/5.3.3'
['8'] => string'P3P: policyref="/bitrix/p3p.xml", CP="NON DSP COR CUR ADM DEV PSA PSD OUR UNR BUS UNI COM NAV INT DEM STA"'
['9'] => string'X-Powered-CMS: Bitrix Site Manager (bc446669bda3fecf3857134c6da9af3b)'
['10'] => string'Set-Cookie: PHPSESSID=2ujm04isb6h1e3tk2ddonr4537; path=/; HttpOnly'
['11'] => string'Expires: Thu, 19 Nov 1981 08:52:00 GMT'
['12'] => string'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
['13'] => string'Pragma: no-cache'
['14'] => string'Set-Cookie: BITRIX_SM_GUEST_ID=256066; expires=Fri, 18-Dec-2015 13:41:12 GMT; path=/'
['15'] => string'Set-Cookie: BITRIX_SM_LAST_VISIT=23.12.2014+16%3A41%3A12; expires=Fri, 18-Dec-2015 13:41:12 GMT; path=/'
['16'] => string'Access-Control-Allow-Origin: *'
['17'] => string'Access-Control-Allow-Headers: Range'
['18'] => string'Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range'
}
我只有FTP访问托管。
我需要尝试什么?
P.S。从站点保存到磁盘,放置按钮 - 正常工作。
非常感谢!
答案 0 :(得分:0)
由于您依赖于Drive SDK并且您拥有凭据,因此无法使用原始通配符作为Access-Control标头。您必须更改此来源以将您的服务器地址指定为来源。