Fork me on GitHub
#reitit
<
2021-10-14
>
wombawomba12:10:35

I'd like to set up different routers for different subdomains (specifically, I want to proxy all traffic to another service for certain values of the Host header) — how can I do make this happen?

Apple12:10:11

Sounds like middleware can be used here which will look into Host header.

wombawomba12:10:58

Hmm yeah I was thinking something like that might work — although, doesn't Retit match routes before calling the middleware stack?

wombawomba12:10:53

...it seems to me like if I go with that approach, I'd have to allow conflicting routes, and create a 'base' route that matches everything — but only does something when the Host header has the appropriate value — and in that case, there's no point in adding that middleware, right?

wombawomba16:10:37

Wait, scratch that. I get it, I need the middleware.

Apple17:10:16

Yeah just wrap a new middleware around the existing handler and middleware always has the option to process before/after existing handler.