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

fix: remove reference to env variables on frontend #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

seungjulee
Copy link
Contributor

@seungjulee seungjulee commented Nov 9, 2023

Copy link

vercel bot commented Nov 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lens-profile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2023 7:42pm
lensv2-profile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2023 7:42pm

app/env.ts Outdated
PROFILE_URL: process.env.PROFILE_URL || "https://lens.k3l.io",
CONTENT_URL: process.env.CONTENT_URL || "https://content.lens.k3l.io",
PROFILE_URL: "https://lens.k3l.io",
CONTENT_URL: "https://content.lens.k3l.io",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the problem is in Vercel and may not be in the code. According to this doc - Declare an Environment Variable using process.env seems to be the right way to go. Can you please confirm this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the problem is that we are trying to load the environment variables on the client component not server rendered component. The client side component that has useEffect can only be referenced from client, and we are calling this call from the client.

I've checked the environment variables, and we already have them imported on Vercel.

I'm not too familiar with Remix, and let me investigate how they work on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's why i was thinking a better fix would be to move the call to getEnv into the export default function HeaderLinks() function in HeaderLinks.tsx and into export default function Index() in the index.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think HeaderLinks and Index are still a client component, and the proper way to solve this problem is to shove it into window like this link. https://remix.run/docs/en/main/guides/envvars#browser-environment-variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants