After a few days of research and some trial & error. I have wildcard subdomains and self-hosting working. I will share the setup I have in the coming days when it’s all working. In short, it’s using a mix of docker, nginx and Traefik to do all the heavy lifting.
Check it out - all the following urls serve the same redwood front-end. This is a staging domain I am using for testing.
https://redwood.uservitalshq.com/
https://yourcompany.uservitalshq.com/
Right now, since I have a slug I need to identify in the URL, I need to figure out how to globally pass through on every page the company slug, found in the domain URI (The *.uservitalshq.com)
Now, not every subdomain slug will exist, so I will need to check the DB, before showing any data.
I’ve looked at a few possible solutions:
- getLocation hook - I could implement something like that and extend support to detect the subdomain slug. I could use this on every page and pass the slug to any cells.
- Also looked at the Redwood Router is implemented, and how the matchPath method is used. Would be great to define this logic on the router but required a lot of core changes.
But before I go overwriting redwood core, I was wondering if anyone else had creative ideas to these problems?