solutions to cors problem

03 Feb 2015

Richard Huang

It's more and more popular that engineers will use different subdomains to build a website, like www for webapp, api for api server, assets for asset host, then you probably face the cors problem.

It can be solved either on app server or web server.

On app server (rails server), you can just add rack-cors gem to fix it.

On web server (apache or nginx), it can also be fixed by server config, the following is a nginx config to fix font cors issue for asset host.

server {

    location ~* \.(eot|ttf|woff)$ {
        add_header Access-Control-Allow-Origin;