Route already used by (other) component


I’ve created an App and wish to have two resources in it, the frontend sitting under mydomain/ and the backend sitting under mydomain/api/.

I’ve created the backend resource first (it’s an express.js app, works, also has its own router) and it is now stuck with serving the /, I can’t find how to change it. I can add more HTTP Request Routes but not remove the root one. When I try to have the frontend serve /, I get the error “Route already in use by the [backend] component”.

How do I make it so that the backend serves mydomain/api/ and the frontend all the other routes including root?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 13, 2023
Accepted Answer

Hi there,

I believe that you should be able to edit the default route rather than adding a new one and then deleting the default route:

  • Go to the App Platform
  • Click on Settings
  • Click on your backend component
  • Scroll down to Routes
  • Change the / route and add the /api prefix
  • Then click the save button

After that try to change the route for the frontend component as well.

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel