CORS and micro-services with

On March 7th 2017 the folks at zeit introduced a new way to compose and coordinate micro-services. In this post I will show you how you can use that to get rid of the CORS header configuration, by using the new aliasing feature. This is made possible because deployments can be configured to be accessible under the same domain.

What is our setup?

  • a rest api - github
  • a frontend - github

What should the result be?

  • the rest api reachable on -
  • the frontend reachable on -

When accessing our api it simply returns a list of strings.

=> Response ["cat","dog","deer"]

When we open the webapp at we get a CORS error. The browser prevents us from requesting data on a different domain than ours. Instead of configuring the headers now, we will use a different solution.

Cors error

What do we have to do?

  • you need an account
  • point the frontend api calls to
  • creating a rules.json file in which we define the paths
  "rules": [
    { "pathname": "/api/*", "dest": "" },
    { "pathname": "/**", "dest": "" },
    { "dest": "" }
  • run now alias -r rules.json

This means that we can access by using and by using

That`s it. We now have the api as well as the frontend reachable under the same domain (, which means that the CORS configuration is not necessary. The cool thing about this is, it can be used for whatever service you want. It is not restricted to deployments.

If you want to read more about that feature go to