Add CORS Headers to Font File Responses in Nginx
nginx
2017-08-14 00:55 (8 years ago)

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;
} Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.