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
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function getEnv() {
return {
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

}

Expand Down