Open dvlden opened 2 years ago
I may be a bit late but I'll put it here in case someone else might encounter the same issue.
the window
object doesn't exist in server environment (the SS in SSR). To solve it simply add a guard:
const url = typeof window === "undefined" ? null : window.location;
Feel free to switch null
with a value you're comfortable with. But just so you know, in JS, usually null
means that we deliberately set the value as such whereas if we were to put ""
(empty string) or undefined
we can't really know whether it was the dev's choice or JS.
As soon as I run
pnpm run dev
I get instant exit with error:What am I doing wrong here?