Best practice for language sub domains in an Express server?
<p>So I have a Node/Express server set up, and we are making the transition from subdirectories to sub domains for localisation, eg:</p>

<pre><code>es.example.com       // old way
www.example.com/es   // new way
</code></pre>

<p>Doing this for a variety of reasons, but mostly to facilitate the preservation of JWT login state across the internationalised content. What is the best practice for allowing this in express when declaring routes?</p>

<p>If I have a route simply set up like this:</p>

<pre><code>app.use('/search')
</code></pre>

<p>Then when I try to hit a route, eg <code>www.example.com/es/search</code>, I will just be redirected to <code>www.example.com/search</code>, the <code>es</code> will be stripped. However, this can be fixed like this:</p>

<pre><code>app.use('*/search')
</code></pre>

<p>I'm sure this must have some negative implications though? How do people typically allow for prefixes in routes via Express?</p>