title: Nextjs production build problem (Links do not work)
body: <p>I have built a website in next.js and expressjs and it works great in development. But when I run <code>next build</code> I get thing that does not occur in development.</p>
  
  <p>I want to write few points that does happen in production only.</p>
  
  <ul>
  <li>Few links do not work</li>
  </ul>
  
  <pre><code>&lt;li style={{marginLeft: '-50px'}}&gt;
       &lt;Link href={`/profile/?user_slug=${router.query.user_slug}`} as={`/profile/${router.query.user_slug}`}&gt;
          &lt;a className={`${classes.textSize} ${router.route === "/profile/user_slug" ? classes.active1 : ''}`}&gt;User&lt;/a&gt;
       &lt;/Link&gt;
  &lt;/li&gt;
  &lt;li&gt;
        &lt;Link  href={`/profile/?user_slug=${router.query.user_slug}/questions`} as={`/profile/${router.query.user_slug}/questions`}&gt;
          &lt;a className={`${classes.textSize} ${router.route === "/profile/user_slug/questions" ? classes.active1 : ''}`}&gt;Ques&lt;/a&gt;
        &lt;/Link&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>Few links in navigation bar do not work when I am on certain page. I have route <a href="https://example.com/profile/user_name" rel="nofollow noreferrer">https://example.com/profile/user_name</a>. Here user_name is dynamic. I have noticed when I am on profile page and if I try to visit home or questions route this does not work.</p>
  
  <p>In layout I have</p>
  
  <pre><code>{!mobile &amp;&amp; &lt;Button className={classes.button}&gt;&lt;Link href='/'&gt;&lt;a className={classes.link}&gt;Home&lt;/a&gt;&lt;/Link&gt;&lt;/Button&gt;}
  {!mobile &amp;&amp; &lt;Button className={classes.button}&gt;&lt;Link href='/questions'&gt;&lt;a className={classes.link}&gt;Questions&lt;/a&gt;&lt;/Link&gt;&lt;/Button&gt;}
  </code></pre>
  
  <p>These two simple links do not work. I don't know why</p>
  
  <ul>
  <li><p>I get error in console saying 404 such as </p>
  
  <p><a href="https://example.com/_next/static/u46GEnW5PnfCBXwLuWy-M/pages/category/%5Bcategory_name%5D.js" rel="nofollow noreferrer">https://example.com/_next/static/u46GEnW5PnfCBXwLuWy-M/pages/category/%5Bcategory_name%5D.js</a> net::ERR_ABORTED 404 (Not Found)</p>
  
  <p><a href="https://example.com/_next/static/u46GEnW5PnfCBXwLuWy-M/pages/question.js" rel="nofollow noreferrer">https://example.com/_next/static/u46GEnW5PnfCBXwLuWy-M/pages/question.js</a> net::ERR_ABORTED 404 (Not Found)</p></li>
  </ul>
  
  <p>I have defined all the routes in express</p>
  
  <pre><code>  app.get('/profile/:user_slug', (req, res) =&gt; {
      return nextApp.render(req, res, '/profile/user_slug', { user_slug: req.params.user_slug })
    })
  
    app.get('/profile/:user_slug/questions', (req, res) =&gt; {
      return nextApp.render(req, res, '/profile/user_slug/questions', { user_slug: req.params.user_slug })
    })
  
    app.get('/profile/:user_slug/followers', (req, res) =&gt; {
      return nextApp.render(req, res, '/profile/user_slug/followers', { user_slug: req.params.user_slug })
    })
  
    app.get('/profile/:user_slug/followings', (req, res) =&gt; {
      return nextApp.render(req, res, '/profile/user_slug/followings', { user_slug: req.params.user_slug })
    })
  
  
  </code></pre>
  
  <p>How do I solve it for production. Everything works great in development.</p>