bmullan91 / express-subdomain

Super simple subdomain middleware for expressjs
414 stars 49 forks source link

* for partial subdomain names #36

Closed tonestrike closed 7 years ago

tonestrike commented 7 years ago

So depending on my environment, the subdomain off an app has a suffix attached like example example-local example-stage. I have tried app.use(subdomain('example*', router))* but that does not work. Any suggestions?

bmullan91 commented 7 years ago

What about conditionally setting a var depending on NODE_ENV... something like:

const subdomainVal = process.env.NODE_ENV === 'development'
  ? 'example-local'
  : 'example-stage';

app.use(subdomain(subdomainVal, router));

Obv if you have more options a ternary wouldn't be the best - but you get the idea :)

tonestrike commented 7 years ago

That is basically exactly what I ended up doing, except I just set dotenv values for the subdomains themselves. Sometimes the obvious solution comes slowly.