solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

Router: domain-based routing #214

Open indeyets opened 1 year ago

indeyets commented 1 year ago

It would be great to have support for domain-based routing. I need to be able to server different pages on different domains.

Could it be configured via additional sub-component of <Routes> maybe?

<Routes>
  <DomainRoutes domain=":language.example.com">
    <Route path="/some-page" component={LocalizedPage} />
  </DomainRoutes>

  <Route path="/some-page" component={DefaultPage} />
</Routes>
indeyets commented 1 year ago

Or should this issue be moved to @solidjs/router instead?

orenelbaum commented 1 year ago

Yeah I think that it should be moved to the router

ryansolid commented 1 year ago

So I understand you have the same site more or less on different domains, and you would like certain routes to only appear on those Domains. The route definition is just JSON ultimately even though we use components, so it could be conditionally constructed I imagine. Unless I'm misunderstanding the use case.

I guess on the server you want to use the request to determine if the routes should be registered and in the client the current URL in the browser?

indeyets commented 1 year ago

Domains might have quite different sets of urls, actually. One case is "search." subdomain which would handle a separate set of "pages"

I talk about generic ability to match over domains in addition to the current ability of matching over paths