redirecting root domain to www (App platform)

Posted November 30, 2020 2.8k views
DNSDigitalOcean App Platform

I’m hosting a website on the new App Platform and i want to run the website on I’ve added that in my App settings and it works.

Now I want to redirect all requests on my root domain ( to

Is that possible ?

1 comment
  • I am trying to do the opposite, I want to redirect www to root. I set up a new app on the www domain to take care of the redirect, but it would be nice to not have to spend $5/month just to redirect www.

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.

Submit an Answer
2 answers

Hi @encantairaq7, this is a planned feature but it is not available yet. For now you will need to update your app to perform this redirect if it is needed.

  • Thanx for the quick reply! By “update your app to perform this redirect if it is needed.” , do you mean to create a seperate droplet to redirect the traffic?

    • If you are running a Service component, you can have it do the redirect. For Static Sites there isn’t a way to do this unfortunately so if this is really needed you can use a Droplet to serve only the non-www hostname and redirect all traffic to www.

      I realize this isn’t ideal so hopefully we can get this feature out soon!

      • Okay cool!
        I’m running a service (react /express app). How exactly can I configure it to redirect to www. ?

        • Your app will have access to the current domain through the Host HTTP header.

          With Express you can use a middleware like forcedomain—see the instructions in the README but it would look something like this:

            hostname: ''

          You could also skip the middleware and inspect the Host header manually but this one seems to be a minimal and well-tested package so it’s probably a good idea to just use it. Let me know if that works!

          Also, you might have to add a condition to enable it only if you are in the production environment so it doesn’t affect your dev workflow, e.g.:

          if (process.env.NODE_ENV == 'production') {
              hostname: ''
      • Hi. Any update on this feature? Thanks!

  • The App platform is really awesome, btw!

I’m using until DO builds this in. Simple and free. Keeps me from having to launch another app or fork out $30/mo to DNSimple for https redirects. Of course, there is also Cloudflare.