Hosting fonts in C9, cross-origin, access-control-allow-origin

nodejs

#1

Hi,

First, really love cloud9, amazing how you seemlessly intigrated the developer tools in a browser! I do though miss the “own app” function due to the complicated tab-shortcut on mac.

I’m quite new to node, and hosting enviroments, and do have a issue conserning cross-domain-access of files. The idea is that i would, in a developing mode, host files such as javascript, images, css, and fonts. And thats were the trouble starts, at fonts. The fonts gets an cross-origin issue since the access-control-allow-origin is not set to “*”. I found the article on node.js and settings here, but have no idea of how to fix this. (Cross-Origin Request Blocked). I tried to add an server.js, with the app-content, but dont se any changes in how the fonts load.

Would be greatfull for help or an step-by-step answer.

PS: Sorry for the poor english :slight_smile:


#2

Can you post the exact errors you’re seeing please. It may be that you are loading them using http:// while loading your site with https://.


#3

Hi,

Sorry for late reply.

Errormessage:
Font from origin ‘https://preview.c9users.io’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://www.spama.no’ is therefore not allowed access.

You can see the error on demosite http://www.spama.no/demo/bank-24-7. This site does not support https so I added an copy/test in dropbox that result in the same error.

We were able to add an .htaccess file that allowed this by running an application, but since the application shut down after a while its not a good demouse.


#4

You should change your <script> tags to just have // at the beginning instead of https:// or http:// before them. Then when you go to http version of spama.no it will load the files over http from Cloud9. See http://stackoverflow.com/questions/6785442/browser-support-for-urls-beginning-with-double-slash for more information.


#5

Hi, thanx for quick reply. Done that change now (did also try this before), but no changes. Its a quite common error that often requires change in .htaccess or httpd.conf. Its all about hosting font-files.

As said we manage to get it to work through launching an apache server (in c9), but it dont stay idle, so its not an good way to develop.

Article about common fixes for the issue: