Add CORS Headers to Font File Responses in Nginx

nginx
2017-08-14 09:55 (7 years ago) ytyng

Here's something often used in Django.

When using Mezzanine and directing static or media files to a CDN, you might frequently encounter CORS errors in Firefox (for example, glyphicon might not be displayed). This is a countermeasure for that.

location ~* ^/static(/(.+\.(eot|ttf|woff)))$ {
add_header Access-Control-Allow-Origin *;
alias /var/django/mydjangoproject/staticfiles$1;
break;
}

location ~ ^/static(/(.+))?$ {
alias /var/django/ydjangoproject/staticfiles$1;
break;
}
location ~ ^/media(/(.+))?$ {
alias /var/django/ydjangoproject/mediafiles$1;
break;
}
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011