Documentation

Several Services on One Domain

Send a path like /api to one service and the rest of your domain to another.

Why use paths

Apps on free hosting are often split up: the frontend on Vercel or Netlify, the API on Render, docs somewhere else. Each one gets its own messy address. With paths, one DomainDock domain serves them all:

  • myapp.digitalweb.host goes to your frontend
  • myapp.digitalweb.host/api goes to your API

Your frontend can then call /api on its own domain, so you don't need to set up cross-origin (CORS) rules between the two.

Add a path

You can add paths while creating a domain (switch on Paths under Options) or later:

  1. Open the domain's page and go to Routing.
  2. Under Paths, click Add path.
  3. Enter the path (like /api) and where it should go: a domain such as myapi.onrender.com or an IP with its port such as 203.0.113.9:4000.
  4. Click Add path. DomainDock checks the target, works out whether it speaks HTTPS or HTTP and applies the change within seconds.
Routing tab: the target with Change target, a path /api to another service and a backup server
Routing holds the target, the paths and the backup server.

A domain can have up to 10 paths.

What a path matches

A path matches itself and everything below it. With the path /api, visits to /api/users and /api/users/42 go to its service. A visit to /apiary does not. When two paths overlap, the longer one wins. If you have both /api and /api/v2, a request to /api/v2/users goes to the /api/v2 service.

Paths are case-sensitive, like the URLs they match. Everything that no path matches goes to the domain's own target.

Keep or remove the path

By default your service receives the full path: a visit to /api/users reaches it as /api/users. If your service expects /users instead, turn on Remove /api before forwarding when you add the path. The form shows a preview of what your service will receive.

On an existing path, click its Keeps /api or Removes /api label to switch. DomainDock asks first, because your service starts receiving different URLs right away.

Removing a path

Click the bin icon on the path. A dialog shows where the path goes and asks you to confirm: its traffic goes back to the domain's own target within seconds.

Confirmation dialog asking before removing the /api path, showing where it goes
Changes visitors would notice ask first.

Good to know

  • Every path is served over HTTPS with the same certificate as the domain.
  • Status checks and down alerts watch the domain's own target. If a path's service is down, visitors to that path see the status page.
  • Paths given as a domain name are looked up again every 5 minutes, so they follow your host when it changes IP.

Try it on your own app

Get a free domain with HTTPS in under a minute. No credit card.

Get your free domain
Newsletter

Developer infrastructure, in your inbox

New guides on domains, SSL certificates and deploying to your own server. A couple of emails a month at most.

No spam. Every email has a one-click unsubscribe.