Is there a way to prepend routes using the API?

1. The problem I’m having:

  • Our system dynamically adds subdomains using the API on http://localhost:2019/config/apps/http/servers/static/routes/
  • Any non-matched subdomain is currently returning a HTTP 200 blank page
  • I’d like that HTTP 200 blank page to be a HTTP 301 to a specific site
  • My assumption is that we need to add an extra handler to end of the route stack, but that would break our current setup, because by default the POST endpoint appends items to the stack

How do I add a route handler in a specific location in the stack?

Use PUT to insert at a specific position. You’ll need to GET the config first, count how many are in the array, then insert it at the 2nd last position.

2 Likes