Font-Face Cross Domain with Nginx
- @font - face {
- font - family: 'PreloSlab';
- src: url('.. / fonts / preloslab - medium - webfont.eot');
- src: url('.. / fonts / preloslab - medium - webfont.eot ? #iefix') format('embedded - opentype'),
- url('.. / fonts / preloslab - medium - webfont.woff') format('woff'),
- url('.. / fonts / preloslab - medium - webfont.ttf') format('truetype'),
- url('.. / fonts / preloslab - medium - webfont.svg#PreloSlabMedium') format('svg');
- font - weight: normal;
- font - style: normal
- }
CSS Font-Face 中字体引用外部资源时, 出现错误: "No'Access-Control-Allow-Origin'header is present on the requested resource" 的解决方案:
1. Nginx 添加配置
- location~ * \. (eot | ttf | woff) $ {
- add_header'Access - Control - Allow - Origin'' * ';
- add_header'Access - Control - Allow - Credentials''true';
- add_header'Access - Control - Allow - Methods''GET,
- POST,
- OPTIONS';
- add_header'Access - Control - Allow - Headers''DNT,
- X - CustomHeader,
- Keep - Alive,
- User - Agent,
- X - Requested - With,
- If - Modified - Since,
- Cache - Control,
- Content - Type';
- }
2.
来源: