I have an App that contains two components, a frontend and a backend. Is it possible map a subdomain to my backend component?
Right now I have a Route path mapped to it but it’s causing issues with Laravel building urls within the app because it doesn’t know it’s running in a “subdirectory”. So all URLS are at the root level.
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!
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.
Hi there,
As KFSys mentioned already, the DigitalOcean App Platform does not currently support mapping subdomains directly to individual components within the same app.
Given this constraint, a practical workaround is to separate your frontend and backend into two distinct apps on the DigitalOcean App Platform. That way you will have full control over the domain mapping.
Additionally, it would be helpful to understand more about the specific issues you’re facing with URL generation in Laravel. If you could share more details about these problems, there might be further advice or solutions we can offer to address these challenges!
For example, as you mentioned, Laravel needs to be aware that it’s running in a subdirectory for it to generate URLs correctly. You can achieve this by setting the
APP_URL
in your.env
file to include the subdirectory. For instance, if your Laravel backend is accessible athttp://yourdomain.com/backend
, setAPP_URL=http://yourdomain.com/backend
.Alternatively, in your Laravel routes (
web.php
orapi.php
), prefix all routes with the subdirectory name. Laravel provides a convenient way to group routes with a prefix, like so:This approach ensures that all your application routes are correctly prefixed with the subdirectory.
Hope that this helps!
Best,
Bobby
Heya @jeremib,
I don’t think that is possible at this moment. Having said that, the best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.
Hope that helps!
- KFSys.