Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CORS #18

Closed
zhangshine opened this issue Jul 17, 2014 · 11 comments
Closed

Enable CORS #18

zhangshine opened this issue Jul 17, 2014 · 11 comments

Comments

@zhangshine
Copy link

firefox 下无法加载webfont

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://apps.bdimg.com/libs/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.woff. This can be fixed by moving the resource to the same domain or enabling CORS. 

downloadable font: download failed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed

source: http://apps.bdimg.com/libs/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.woff
@huang-xin
Copy link
Contributor

how?

@zhangshine
Copy link
Author

不知道你们用什么服务器, nginx的 http://stackoverflow.com/a/17273542

@huang-xin
Copy link
Contributor

我是想知道你是用的什么方法引用的静态资源

@zhangshine
Copy link
Author

Firefox下

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
    <span class="glyphicon glyphicon-star"></span>
</body>
</html>

@huang-xin
Copy link
Contributor

多谢,我们马上解决。

@huang-xin
Copy link
Contributor

fixed

@zhangshine
Copy link
Author

还是有同样的问题,返回的header里面并没有Access-Control-Allow-Origin: * ,只好暂时用staticfile.org了

@huang-xin
Copy link
Contributor

Access-Control-Allow-Method:GET
Access-Control-Allow-Origin:*
确认已经加上了

@zhangshine
Copy link
Author

只有eot文件加上了,ttf和woff都没有, IE用eot, firfox用woff

@huang-xin
Copy link
Contributor

location ~* \.(ttf|ttc|otf|eot|woff)$ {
    add_header  Access-Control-Allow-Origin "*";
    add_header  Access-Control-Allow-Method "GET";
}

Chrome, FireFox下测试woff也是ok的,麻烦看看你那是否有缓存或者反向代理了。

@zhangshine
Copy link
Author

第一张图是我本地(上海)请求的header, 第二张是从美国的一个vps上请求的header, 都是3.1.1版本的加上了, 3.2版本的没有. 不纠结了, 能用就好了.

screenshot from 2014-07-25 13 44 27
usa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants