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

百度域下字体403 forbidden #1070

Closed
hxlniada opened this issue Feb 24, 2016 · 16 comments
Closed

百度域下字体403 forbidden #1070

hxlniada opened this issue Feb 24, 2016 · 16 comments

Comments

@hxlniada
Copy link

百度内部的项目,发现访问字体的时候403 forbidden,
请问有什么方法通过么?

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

字体是托管在 http://iconfont.cn/ 上的,公网可用。是否网络环境有限制?

@hxlniada
Copy link
Author

不是,我就是把host配成xx.baidu.com。就不行了

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

看下网络请求是否有错误,控制台是否有字体文件跨域相关的报错。

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

貌似是有这个问题,我正在咨询相关人员。

@insekkei
Copy link

@hxlniada,我已经下载到本地使用...src/common/lib.js中的css引用路径改一下,然后把antd/lib/index.css copy出来,里面的字体路径都修改下...

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

@hxlniada 可以先本地部署。http://ant.design/docs/resource/download

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

本地部署 iconfont 可参考这个例子:https://github.com/ant-design/antd-init/tree/7c1a33cadb98f2fd8688fe527dd7f98215b9bced/examples/local-iconfont

@afc163
Copy link
Member

afc163 commented Feb 24, 2016

alicdn 对百度域做了访问限制,先按本地部署来解决。

@afc163 afc163 closed this as completed Feb 24, 2016
@someok
Copy link

someok commented Feb 24, 2016

这个其实是因为字体图标的 url 采用的前缀是 //at.xxx

可以创建一个开发环境下的 less:

@import "~antd/style/index.less";

@import "custom.less";

@icon-url: "http://at.alicdn.com/t/font_1452596235_7047422";

On Wed, Feb 24, 2016 at 6:12 PM 偏右 notifications@github.com wrote:

Closed #1070 #1070.


Reply to this email directly or view it on GitHub
#1070 (comment).

@fengmk2
Copy link
Contributor

fengmk2 commented Mar 1, 2016

尴尬。。。

@Flourad
Copy link

Flourad commented Mar 16, 2016

http://ant.design/docs/resource/download下载web font放在项目目录下引用之后,怎么在代码里引用图标?按照原来的方式这样,图标无法显示?

@Dafrok
Copy link
Contributor

Dafrok commented Jul 20, 2016

alicdn除了百度域还对别的域做限制吗……最好有个black list 以免耽误不必要的时间排查此类问题

@afc163
Copy link
Member

afc163 commented Jul 20, 2016

这个我们也不了解。。。

@ghost
Copy link

ghost commented Aug 17, 2016

image
还真是对百度域拦截了

@yankun01
Copy link

我累个去。。。。

@drawcall
Copy link

drawcall commented Sep 6, 2017

使用StringReplacePlugin,就可以一步绕过吧

{
    test: /\.(css|less|js|jsx)$/,
        loader: StringReplacePlugin.replace({
            replacements: [
                {
                    pattern: new RegExp('https://at.alicdn.com/t/', 'ig'),
                    replacement: function (match, p1, offset, string) {
                        return '/assets/fonts/';
                    }
                }
            ]
        })
}

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

9 participants