title: Next js failing on build with getStaticProps due to param being undefined
body: <p>weird error started appearing that's causing builds to fail,</p>
  <p>we have a post/[id].tsx file inside of our pages dir, this file uses <code>getStaticProps</code> and <code>getStaticPaths</code></p>
  <p>-- props</p>
  <pre><code>export const getStaticProps: GetStaticProps = async ({ params }) =&gt; {
    const res: Response = await fetch(`${baseUrl}/api/products/${params.id}`);
  
    const data: Product[] = await res.json();
  
    return {
      props: {
        data,
      },
    };
  };
  </code></pre>
  <p>-- paths</p>
  <pre><code>export const getStaticPaths: GetStaticPaths = async () =&gt; {
    const res: Response = await fetch(`${baseUrl}/api/products`);
    const { data } = await res.json();
  
    const paths = data.map((product: Product) =&gt; ({
      params: { id: product.id.toString() },
    }));
    return { paths, fallback: &quot;blocking&quot; };
  };
  </code></pre>
  <p>running <code>npm run dev</code> locally and everything works as expected, but running <code>npm run build</code> and the error</p>
  <pre><code>Type error: Object is possibly 'undefined'.
  </code></pre>
  <p>inside of the getStaticProps function</p>
  <pre><code>&gt; 12 |   const res: Response = await fetch(`${baseUrl}/api/products/${params.id}`);
                                                                        ^
  </code></pre>
  <p>Now the weird thing is that the currently deployed build on vercel is using the exact same code to  build this page and nothing has changed from it. But now builds are suddenly failing?</p>