<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>


<p dir="auto">A link using <code class="notranslate">prefetch</code> and pointing to a non-existent url should show the standard 404 page.:</p>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;Link prefetch href=&quot;/bad-url&quot; /&gt;"><pre class="notranslate"><span class="pl-kos">&lt;</span><span class="pl-ent">Link</span> <span class="pl-c1">prefetch</span> <span class="pl-c1">href</span>="<span class="pl-s">/bad-url</span>" /&gt;</pre></div>
<h2 dir="auto">Current Behavior</h2>


<p dir="auto">The browser does not navigate anywhere, and so it looks like the link is unresponsive.</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li>Add</li>
</ol>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;Link prefetch href=&quot;/bad-url&quot; /&gt;"><pre class="notranslate"><span class="pl-kos">&lt;</span><span class="pl-ent">Link</span> <span class="pl-c1">prefetch</span> <span class="pl-c1">href</span>="<span class="pl-s">/bad-url</span>" /&gt;</pre></div>
<p dir="auto">to a page</p>
<ol start="2" dir="auto">
<li>Click on it, notice the browser does nothing.</li>
</ol>
<h2 dir="auto">Context</h2>


<p dir="auto">Because this has to do with <code class="notranslate">prefetch</code>, this is production-only. Not sure if it matters, but this is a client-side only app hosted on Netlify.</p>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>4.2.3</td>
</tr>
<tr>
<td>node</td>
<td>N/A, client-side only</td>
</tr>
<tr>
<td>OS</td>
<td>OS X 10.13.4</td>
</tr>
<tr>
<td>browser</td>
<td>Chrome</td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// next.config.js
module.exports = {distDir: 'build/local/prod'}"><pre class="notranslate"><code class="notranslate">// next.config.js
module.exports = {distDir: 'build/local/prod'}
</code></pre></div>
<p dir="auto">Run this. Note that the <code class="notranslate">distDir</code> is being taken from the config.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import config from './next.config.js'
const {distDir} = config

nextBuild(distDir, config)
  .then(o =&gt; {
    console.log('finished', o)
  })
  .catch(e =&gt; {
    console.log('build error', e)
  })"><pre class="notranslate"><code class="notranslate">import config from './next.config.js'
const {distDir} = config

nextBuild(distDir, config)
  .then(o =&gt; {
    console.log('finished', o)
  })
  .catch(e =&gt; {
    console.log('build error', e)
  })
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ npm start

&gt; Could not find a valid build in the 'build/local/prod' directory! Try building your app with 'next build' before starting the server."><pre class="notranslate"><code class="notranslate">$ npm start

&gt; Could not find a valid build in the 'build/local/prod' directory! Try building your app with 'next build' before starting the server.
</code></pre></div>
<p dir="auto">In <code class="notranslate">replace.js</code>, <code class="notranslate">await replaceCurrentBuild(dir, buildDir)</code>, all the variables are as follows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ dir: 'build/local/prod',
  buildDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd',
  dist: '.next',
  _dir: 'build/local/prod/.next',
  _buildDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd/.next',
  oldDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd/.next.old' }"><pre class="notranslate"><code class="notranslate">{ dir: 'build/local/prod',
  buildDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd',
  dist: '.next',
  _dir: 'build/local/prod/.next',
  _buildDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd/.next',
  oldDir: '/var/folders/kp/06ys69nn6hq9k23cv0xxn19m0000gn/T/a224b0f3-c8ea-43f5-a6dd-c6cfb73843bd/.next.old' }
</code></pre></div>
<p dir="auto"><code class="notranslate">.next</code> is being appended to the dir. But when we try to run it it, we are not looking for the <code class="notranslate">.next</code>  dir because we changed our dist dir.</p>



<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>4.1.3</td>
</tr>
<tr>
<td>node</td>
<td>8.1.2</td>
</tr>
<tr>
<td>OS</td>
<td>macOS</td>
</tr>
<tr>
<td>browser</td>
<td></td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>