Question

Configuring access conrol allow origin

Access to font at ‘https://acsess.sgp1.digitaloceanspaces.com/acsess/plugins/fonts/outline-icons.ttf’ from origin ‘http://localhost:8000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

These are one of the files from collectstatic.

This is the error I get on my spaces account.

I am using Django with Boto3 and django-storages.

How can I get these files to work.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @acsfess,

Django by default does not provide the headers necessary to provide cross origin. The easiest way would be to just use this Django app that handles it for you: https://github.com/ottoyiu/django-cors-headers

You can then set whichever domains you want white listed using the settings

CORS_ORIGIN_WHITELIST = (
    'google.com',
    'hostname.example.com'
)

to support allowing all, just use the setting… CORS_ORIGIN_ALLOW_ALL = True and then do any filtering of the request in the middleware or in the view.

Regards, KDSys