问题描述
有没有办法为上托管的静态网页启用跨源资源共享(CORS),以允许跨源
Is there a way to enable Cross-Origin Resource Sharing (CORS) for a static page hosted on GitHub Pages to allow cross-origin requests in Javascript?
例如,我们可以指示GH Pages以某种方式添加这些HTTP响应标头:
For example, can we instruct GH Pages somehow to add these HTTP response headers:
Access-Control-Allow-Origin:*
Access-Control-Allow-Methods:GET,POST
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers:*
未能在其,以及此...
Couldn't find anything in their documentation, and this ...
... doesn't sound very promising - or is there a way?
推荐答案
编辑: / strong> Yay!看起来GitHub网页现在支持CORS: https://twitter.com/invisiblecomma/status/575219895308324864 这可以通过curling一个请求到enable-cors.org(托管在GitHub页面上)来验证。运行此命令: This can be verified by curling a request to enable-cors.org (which is hosted on GitHub Pages). Running this command: 这篇关于GitHub页面上的跨源资源共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! curl -v enable-cors.org> / dev / null
返回 Access-Control-Allow-Origin:*
标题。curl -v enable-cors.org > /dev/null
returns an Access-Control-Allow-Origin: *
header.