<h1 dir="auto">Feature request</h1>
<h2 dir="auto">Is your feature request related to a problem? Please describe.</h2>
<p dir="auto">Next.js v9.0.0 hard codes the root API directory path to <code class="notranslate">/pages/api</code></p>
<p dir="auto">Making this a config option would allow for a better separation of concerns.</p>
<p dir="auto">We consider pages just that, pages, each one relates to a page you can visit, where as the API is the API an endpoint we consume. Because we are also connecting to a graphql backend to consume our data (which allows you to request everything in a single request) and since the release of serverless pre-rendering we are creating an endpoint for each of our pages to consume, i.e. api/pages/index etc... so right now that looks like /pages/api/pages/index, which gets confusing.</p>
<h2 dir="auto">Describe the solution you'd like</h2>
<p dir="auto">A config option to be able to specify the API direction path.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const path = require('path')

module.exports = {
  apiDir: path.resolve(__dirname, 'api'),
}"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">path</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'path'</span><span class="pl-kos">)</span>

<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">apiDir</span>: <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">__dirname</span><span class="pl-kos">,</span> <span class="pl-s">'api'</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>
<h2 dir="auto">Describe alternatives you've considered</h2>
<p dir="auto">n/a</p>
<h2 dir="auto">Additional context</h2>
<p dir="auto"><a href="https://spectrum.chat/next-js/general/next-9-is-there-a-config-option-to-change-where-the-api-dir-is-located~81da11ce-cd38-4fb5-bcda-9e95ee07db14" rel="nofollow">https://spectrum.chat/next-js/general/next-9-is-there-a-config-option-to-change-where-the-api-dir-is-located~81da11ce-cd38-4fb5-bcda-9e95ee07db14</a></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>
<p dir="auto">egg.js: <a href="https://github.com/eggjs/egg">https://github.com/eggjs/egg</a></p>
<p dir="auto">In this example: <a href="https://github.com/zeit/next.js/blob/master/examples/custom-server-koa/server.js">https://github.com/zeit/next.js/blob/master/examples/custom-server-koa/server.js</a>. <strong><code class="notranslate">ctx.respond = false</code></strong> causes a large number of koa middleware to be invalid. <code class="notranslate">egg.js</code> is based on<code class="notranslate">koa</code> implementation.</p>
<h2 dir="auto">Expected Behavior</h2>


<h2 dir="auto">Current Behavior</h2>


<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
<h2 dir="auto">Context</h2>


<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>v3</td>
</tr>
<tr>
<td>node</td>
<td>8.4</td>
</tr>
<tr>
<td>OS</td>
<td>mac</td>
</tr>
<tr>
<td>browser</td>
<td>*</td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>