Keep route prefix when using route in App Platform

I have a spec app.yml that I use to setup a service and a frontend in the App platform (I trimmed down the yaml file):

name: airmeeple

- name: frontend
  source_dir: frontend
  - path: /

- name: backend
  source_dir: backend
  - path: /api

When DO re-routes requests to the backend, it strips the prefix /api such that if the request, the service will receive the request /user.

Is it possible to configure the reverse proxy such that the prefix is kept when rerouting the request, such that the service sees a request with the path /api/user?

Thanks in advance!

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.

Accepted Answer

@yehudi @mirkul This was added by DO, there is now a preserve_path_prefix when configuring a route that allows the prefix to be kept.

DigitalOcean Employee
DigitalOcean Employee badge
September 27, 2021

Hey @Longwelwind,

it looks like our backend infrastructure is currently going to rewrite the host to “/” when making a routeable upstream for all services. I hear you about wanting to retain the path. I think when our team first built this, they expected that you would want to have your application route for itself, but I think your suggestion is totally valid. Currently, we always rewrite the host for apps, but I’ll see about implementing this customization.

Same here

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