0

I noticed that when I go to the route "/stream/[provider]/[streamerId]" in my browser the page loads successfully, but I can also see the page also prints to console a 404 stating that the url is "/stream/YouTube/null", even though I passed in the url "/stream/YouTube/ucyazpsxowcye_ffhs-jurcw" for example. I would like for the undesired URL to never show, since it is simply not the case of the value [streamerId] not being provided.

The directory of the page that is rendering this page is /stream/[provider]/[streamerId]/index.tsx by the way.

In my getServerSideProps function, I added a null check for streamerId so that it returns a notFound error before it performs any additional logic, but it turns out that null is being passed as a string, so the following conditional was needed:

if (!streamerId || streamerId === "null") {
  return {
    notFound: true,
  };
}

I checked in our server/index.js file too and wrote the following code to log the URL, and noticed that pathName sometimes contains the correct route "/stream/YouTube/ucyazpsxowcye_ffhs-jurcw", and other times it will print "/stream/YouTube/null":

app.get(
  "*",
  syncMuid,
  syncLocaleAndRoute,
  addSecurityHeaders,
  cacheMiddleware,
  (req, res) => {
    const { path: pathName, query } = req;
    console.log("pathname--------------", pathName);
    console.log("query-----------------", query);

    return nextHandler(req, res);
  }
);

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • I'd like to also mention that I checked inside all of those handlers inside the `app.get` function call and they are also producing the same behavior where somtimes it passes in the correct URL, and other times it passes in streamerId = null – James Boultinghouse Mar 09 '23 at 21:06

0 Answers0