Issue with server.msj

I've updated the .env to something like this:
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=supersecret
DATABASE_URL=mysql://[email protected]/demo-system?sslaccept=strict
NEXT_PUBLIC_AWS_ACCESS_KEY_ID=key
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY=key
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=supersecret
DATABASE_URL=mysql://[email protected]/demo-system?sslaccept=strict
NEXT_PUBLIC_AWS_ACCESS_KEY_ID=key
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY=key
I've also updated the schema as it's written in the docs.
export const clientSchema = z.object({
// NEXT_PUBLIC_CLIENTVAR: z.string(),
NEXT_PUBLIC_AWS_ACCESS_KEY_ID: z.string(),
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY: z.string(),
});

export const clientEnv = {
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
NEXT_PUBLIC_AWS_ACCESS_KEY_ID: process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID,
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY:
process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY,
};
export const clientSchema = z.object({
// NEXT_PUBLIC_CLIENTVAR: z.string(),
NEXT_PUBLIC_AWS_ACCESS_KEY_ID: z.string(),
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY: z.string(),
});

export const clientEnv = {
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
NEXT_PUBLIC_AWS_ACCESS_KEY_ID: process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID,
NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY:
process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY,
};
but now this error is appearing for no reason as you can see I'm also console logging the key but that shouldnt be a reason for the error. anyone seen some similar behavior and knows how to fix it?
4 Replies
Sean Cassiere
Sean Cassiere2y ago
Remove the NEXT_PUBLIC_ prefix It should be like
AWS_ACCESS_KEY_ID=key
AWS_SECRET_ACCESS_KEY=key
AWS_ACCESS_KEY_ID=key
AWS_SECRET_ACCESS_KEY=key
barry
barry2y ago
yh you dont want your aws keys public lol
Sean Cassiere
Sean Cassiere2y ago
This prefix should only be used when it is safe to be exposed to the client-side, and anything specifically for the server should NOT be exposed to the client.
Forsto
ForstoOP2y ago
thanks for the help the issue ended up being that i was importing the server env instead of the client one
Want results from more Discord servers?
Add your server