Hi,
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?
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!
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:
/
route and add the /api
prefixAfter that try to change the route for the frontend component as well.
Let me know how it goes!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.