Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Hydration Warnings #1742

Open
tomosovich opened this issue Jan 27, 2024 · 2 comments
Open

bug: Hydration Warnings #1742

tomosovich opened this issue Jan 27, 2024 · 2 comments
Labels
🚫 cant reproduce The bug described could not be reproduced 🐞❔ unconfirmed bug

Comments

@tomosovich
Copy link

Provide environment information

"initVersion": "7.26.0"

Describe the bug

A lot of hydration warnings on a fresh run of the scaffold, suppressing the hydration warning didn't change anything. And this bug doesn't happen when deployed to vercel.

Reproduction repo

NA

To reproduce

Scaffold out the build (Prisma, authJS, tailwind)

Additional information

I believe this is happening due to the browser check when establishing the base URL. Compare the following:

function getBaseUrl() { if (typeof window !== "undefined") return ""; if (process.env.VERCEL_URL) return https://${process.env.VERCEL_URL}; return http://localhost:${process.env.PORT ?? 3000}; }

When I change the code to

function getBaseUrl() { if (document) return ""; if (process.env.VERCEL_URL) return https://${process.env.VERCEL_URL}; return http://localhost:${process.env.PORT ?? 3000}; }

The error clears up. Is there any downside to using document instead of type window to establish where the code is being executed?

@tomosovich
Copy link
Author

I can share a repo if needed, and if you'd like me to submit a PR, it's a pretty small changes so anyone can do it.

@juliusmarminge
Copy link
Member

reproductino would be helpful, i've never run into issues with typeof window check

@juliusmarminge juliusmarminge added the 🚫 cant reproduce The bug described could not be reproduced label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚫 cant reproduce The bug described could not be reproduced 🐞❔ unconfirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants