#Subdomain as Route

1 messages · Page 1 of 1 (latest)

ruby pebble
sinful jetty
#

The router doesn’t have anything to define subdomains, you would have to check the request.url to get the origin of the url (domain) and verify the subdomain yourself

tribal mist
#

you will need to handle this replacement before the request gets handled by remix. This depends on what stack/hosting provider you are using. Basically you'll change the request.url from subdomain.mydomain.com/path to mydomain.com/subdomain/path before passing it to createRequestHandler. I did this using aws lambda successfully, but not sure how it would work in an express-style host.

ruby pebble
sinful jetty
#

you could have a function like this

function getSubdomain(request: Request) {
  let { hostname } = new URL(request.url);
  let [subdomain] = hostname.split(".")
  return subdomain
}

and use it in every loader to know the subdomain of the request.url

tribal mist
#

well if you want to basically make remix treat it as a path name, (ie to use as a param) you need to modify it pre-remix

sinful jetty
#

it will not work client-side

#

because client-side the route will expect the subdomain to be part of the pathname

ruby pebble
#

hmm.. would i be better off creating 2 apps..

one for splash page registration .. and the second for the client's app..

im trying to kinda clone what shopify does with there accounts.. where when you register you get assigned a domain name... and then the users of that domain name can have sub users with limited access...

#

essentially just smoke screening the url lol kind of like how when you create a shopify account... your login page is yourdomain.myshopify.com

ruby pebble
sinful jetty
ruby pebble
turbid vector
#

I do an initial check on the root for subdomain styling if any. And then use a similar function for each loader/action to check for things like auth, etc

ruby pebble
turbid vector
ruby pebble
turbid vector
turbid vector
#

You’ll still need to add your port in the browser when accessing

#

On dev