GitHub页面上的跨源资源共享 [英] Cross-Origin Resource Sharing on GitHub Pages

查看:351
本文介绍了GitHub页面上的跨源资源共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为 GitHub Pages 上托管的静态网页启用跨源资源共享(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 ...


... GitHub Pages不支持客户服务器配置文件
,例如.htaccess或.conf ...

...GitHub Pages does not support customer server configuration files such as .htaccess or .conf...



... 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页面上)来验证。运行此命令: curl -v enable-cors.org> / dev / null 返回 Access-Control-Allow-Origin:* 标题。

This can be verified by curling a request to enable-cors.org (which is hosted on GitHub Pages). Running this command: curl -v enable-cors.org > /dev/null returns an Access-Control-Allow-Origin: * header.

在GitHub页面上没有办法支持CORS,虽然我很想看到这个功能。我们在GitHub页面上托管 http://enable-cors.org ,我们无法在网站本身:)

There's no way to support CORS on GitHub Pages, though I'd love to see this feature. We host http://enable-cors.org on GitHub Pages, and we can't enable CORS on the site itself :)

这篇关于GitHub页面上的跨源资源共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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