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

Cross-Origin Request on docs webfonts #13593

Closed
KokaKiwi opened this issue Apr 18, 2014 · 5 comments
Closed

Cross-Origin Request on docs webfonts #13593

KokaKiwi opened this issue Apr 18, 2014 · 5 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@KokaKiwi
Copy link

When I browse the Rust API docs with Firefox Nightly, the fonts aren't loaded and I have these errors on the console;

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://rust-lang.org/fonts/Heuristica-Regular.woff. This can be fixed by moving the resource to the same domain or enabling CORS. Heuristica-Regular.woff
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://rust-lang.org/fonts/FiraSans-Regular.woff. This can be fixed by moving the resource to the same domain or enabling CORS. FiraSans-Regular.woff
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://rust-lang.org/fonts/Heuristica-Italic.woff. This can be fixed by moving the resource to the same domain or enabling CORS. Heuristica-Italic.woff
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://rust-lang.org/fonts/FiraSans-Medium.woff. This can be fixed by moving the resource to the same domain or enabling CORS. FiraSans-Medium.woff
downloadable font: download failed (font-family: "Heuristica" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed
source: http://rust-lang.org/fonts/Heuristica-Regular.woff main.css
downloadable font: download failed (font-family: "Fira Sans" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed
source: http://rust-lang.org/fonts/FiraSans-Regular.woff main.css
downloadable font: download failed (font-family: "Heuristica" style:italic weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed
source: http://rust-lang.org/fonts/Heuristica-Italic.woff main.css
downloadable font: download failed (font-family: "Fira Sans" style:normal weight:500 stretch:normal src index:1): bad URI or cross-site access not allowed
source: http://rust-lang.org/fonts/FiraSans-Medium.woff

I'm using the latest Firefox Nightly (31.0a1)

@yuriks
Copy link
Contributor

yuriks commented Apr 19, 2014

In addition, fonts are being loaded from http://rust-lang.org/, which currently simply timeouts, instead of http://www.rust-lang.org/ which works. This is probably a server configuration bug.

@yuriks
Copy link
Contributor

yuriks commented Apr 20, 2014

The www issues seems to have been fixed today, but the CSRF problem remains. I'd like to note that this also happens with the regular Firefox release, not just in nightly.

@huonw
Copy link
Member

huonw commented Apr 27, 2014

cc @adrientetar @thehydroimpulse

@adrientetar
Copy link
Contributor

Yes I noticed that Firefox does not like cross-origin (unlike Chrome), so my approach in my last PR was to upload the fonts locally on the built doc/ folder however there's a 403 forbidden status from the server at static.rust-lang.org, we would need to while-list to filetype – cc @brson.

@adrientetar
Copy link
Contributor

@brson: the fix to allow webfonts consists of adding the following to .htaccess on the Apache server:

# ------------------------------------------------------------------------------
# | Web fonts access |
# ------------------------------------------------------------------------------

# Allow access to web fonts from all domains.

<IfModule mod_headers.c>
    <FilesMatch "\.(eot|otf|tt[cf]|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

(Only WOFF is required here.)

This code snippet comes from H5BP boilerplate configuration (it is a good default for servers).

bors added a commit that referenced this issue Apr 30, 2014
Two selector fixes for rustdoc:

- links colored in blue (#13807) was also affecting headers, which are anchored to their respective ids
- the header unstyling from #13776 was being applied to all headers also

Additionally, remove a stray title in the documentation. This makes the crate title of prelude appear as header instead of an inline paragraph of text (all others work normally and do not have that header tag).

The design is unchanged from my previous template (e.g. [here](http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm)), however it is now properly applied.  
The last fix remaining is to enable webfonts service from `static.rust-lang.org`, this is #13593.

r? @alexcrichton, @brson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants