title: Next.js not build when using getStaticPaths and props
body: <p>I'm trying to run <code>next build</code> when using <code>getStaticProps</code> and <code>getStaticPaths</code> method in one of my routes, but it fails every time. Firstly, it just couldn't connect to my API (which is obvious, they're created using Next.js' API routes which are not available when not running a Next.js app). I thought that maybe running a development server in the background would help. It did, but generated another problems, like these:</p>
  <pre><code>Error: Cannot find module for page: /reader/[id]
  Error: Cannot find module for page: /
  &gt; Build error occurred
  Error: Export encountered errors on following paths:
          /
          /reader/1
  </code></pre>
  <p>Dunno why. Here's the code of /reader/[id]:</p>
  <pre><code>const Reader = ({ reader }) =&gt; {
    const router = useRouter();
  
    return (
      &lt;Layout&gt;
        &lt;pre&gt;{JSON.stringify(reader, null, 2)}&lt;/pre&gt;
      &lt;/Layout&gt;
    );
  };
  
  export async function getStaticPaths() {
    const response = await fetch(&quot;http://localhost:3000/api/readers&quot;);
    const result: IReader[] = await response.json();
  
    const paths = result.map((result) =&gt; ({
      params: { id: result.id.toString() },
    }));
  
    return {
      paths,
      fallback: false,
    };
  }
  
  export async function getStaticProps({ params }) {
    const res = await fetch(&quot;http://localhost:3000/api/readers/&quot; + params.id);
    const result = await res.json();
    return { props: { reader: result } };
  }
  
  export default Reader;
  </code></pre>
  <p>Nothing special. Code I literally rewritten from the docs and adapted for my site.</p>
  <p>And here's the <code>/api/readers/[id]</code> handler.</p>
  <pre><code>export default async function handler(
    req: NextApiRequest,
    res: NextApiResponse
  ) {
    const knex = getKnex();
    const { id } = req.query;
  
    switch (req.method) {
      case &quot;GET&quot;:
        try {
          const reader = await knex
            .select(&quot;*&quot;)
            .from(&quot;readers&quot;)
            .where(&quot;id&quot;, id)
            .first();
  
          res.status(200).json(reader);
        } catch {
          res.status(500).end();
        }
  
        break;
    }
  }
  </code></pre>
  <p>Nothing special either. So why is it crashing every time I try to build my app? Thanks for any help in advance.</p>