Phoenix with wildcard subdomain

I’m looking for some help in properly configuring a Phoenix (umbrella) app to work nicely while running on a *.myapp.com host. The context here is that I need to drive white-labeling through the subdomain like clientname.myapp.com.

The way I’ve configured it so far doesn’t seem right. I’ve got the endpoint configured like so:

config :redacted_web, RedactedWeb.Endpoint,
  url: [host: "myapp.com"]

And a plug which pulls out the subdomain with some regex and fetches the account. This works for the most part but there’s a few annoyances. For instance, I can’t use redirect(to: path) and have to instead do redirect(external: uri). I suppose that’s fine but it’s also making testing a pain when asserting redirected_to.

Not a huge deal. But would be great to know if I’m going about this wrong. The app will always be running on a subdomain. myapp.com is a separate sales site.

1 Like