Skip to content

Instantly share code, notes, and snippets.

@amigrave
Last active June 3, 2021 23:39
Configure Odoo with Keycdn

Support for CDN has been added to Odoo in master branch.

Just tested with KeyCDN and the setup was straightforward.

##Step 1: Create a pull zone in the KeyCDN dashboard

create a pull zone

While creating the zone, enable the CORS option in the advanced features submenu. (more on that later)

enable CORS

Once done, you'll have to wait a bit while KeyCDN is crawling your website.

progress bar

Note that an url has been provided for your Zone, in this test case, the url is http://pulltest-b49.kxcdn.com

##Step 2: Configure the odoo instance with your zone

In the odoo backend, go to the Website Settings menu, then activate the CDN support and copy/paste your zone url in the CDN Base URL field.

CDN Base URL

Now your website is using the cdn for the resources matching the CDN filters regular expressions.

Check the html of your website to see if the CDN integration is properly working.

check your html

##Why should I activate CORS?

A security restriction in Firefox and Chrome (at time of writing) prevents a remotely referenced CSS file to fetch resources on the external server. This is the case for the font-awesome lib used in odoo.

Without CORS enabled on the remote CDN, the font file won't be loaded and here's what you will see instead of font-awesome icons:

font file not loaded

A security error message will appear in the console:

security message

In this case, just activate the CORS option in the CDN:

enable CORS

and the CSS resources will be loaded:

font loaded

@Benniphx
Copy link

Hi i have a question:
I tried the CDN support and found one error or an not so good workaround.
Then I have an CDN active it works like a charm, but then i when use the website builder and save my changes the CDN links are hard copied in the views. So i have to manually change them back if i do not want to use this CDN anymore. is there a way or a commit you can show me how i may automatically set the CDN deactivate then i use edit in the front-end ?

@zydest
Copy link

zydest commented Feb 17, 2016

I add the cdn as this tutorial said, but does not work.:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment