Search code examples
reactjsnext.jsweb-deploymentnetlifyvercel

Nextjs deployed on Vercel = blank page


I managed to deploy my Nextjs app (whith getStaticProps + i18n + firebase) on Vercel. But i get a blank screen. Here's the log:

Status: 200
Duration: 8.18ms
Memory Used: 111 MB

I tried :

  • Checking the build function locally: it works perfectly.
  • Changing the default build and development settings to these (with no luck) :

enter image description here

  • I even tried to deploy on netlify (even thought i don't think they support i18n because i18n doesn't support next export), but i get a 404 page, which is the equivalent of a blank page in Vercel.

I also tried:

  1. Creating a new git and re-deploying. But I still get an empty result after a perfect deploy with a list of all my pages and stuff...
  2. Deleting i18n.
  3. Deleting index.html from public
  4. Deleting all pages but one.
  5. Deleting _document.jsx
  6. Deleting every public folder pages except assets like images.
  7. Deleting package lock file. Stil nothing works. And yet, i get a perfect previw of my webapp in Vercel, but the link goes to a blank page.

enter image description here

Any idea?


Solution

  • My mistake. It was a problem with my getServerSideProps code

    To this :

    export async function getServerSideProps({ req, res }) {
      const data = cookie.parse(req ? req.headers.cookie || "" : document.cookie);
    
      if (res) {
        if (Object.keys(data).length === 0 && data.constructor === Object) {
          res.end();
        }
      }
    
      return {
        props: { userId: data.userId }, // will be passed to the page component as props
      };
    }

    I went to this:

    export async function getServerSideProps({ req, res }) {
      const data = cookie.parse(req ? req.headers.cookie || "" : document.cookie);
    
      return {
        props: { userId: data.userId }, // will be passed to the page component as props
      };
    }

    The res.end(); was the problem.