Next.js Discord

Discord Forum

Checking if UserId is same with .env doesnt work.

Answered
aliyorulmazdev posted this in #help-forum
Open in Discord
  const userIdFromEnv = process.env.USER_ID;
  const { userId } = useAuth();
  if (userId !== userIdFromEnv) {
    return <div>You are not authorized for this saloon.</div>;
  }

this just doesnt work i dont know why. If i write userId directly here without using .env it works but i need to get it from .env file.
Answered by aliyorulmazdev
NEXT_PUBLIC_USER_ID instead of USER_ID fixed it.
View full answer

1 Reply

NEXT_PUBLIC_USER_ID instead of USER_ID fixed it.
Answer