src/server/utils.ts ```ts import 'server-only' export function getEnv(): Env { const grc = getReq

src/server/utils.ts
import 'server-only'

export function getEnv(): Env {
  const grc = getRequestContext().env as unknown as Env;

  if (grc.SECRET_KEY != null) {
    return grc;
  } else if (process.env.SECRET_KEY != null) {
    return process.env as unknown as Env;
  } else {
    throw new Error("Env variables are not defined");
  }
}

is this fine?
getRequestContext()
and
process.env
is still very confusing. sometimes they work in local, sometimes they dont work in prod, so i made this utility function
Was this page helpful?