Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Using a value from the .env file and using it in createSecretKey returns error

I'm basically doing this:

const secretKey = crypto.createSecretKey(
    Buffer.from(process.env.SECRET, "hex")
  );

And I get the following error: "The value of "key.byteLength" is out of range. It must be > 0. Received 0"

Replacing the process.env.SECRET with the secret itself works.

export const createToken = async (id) => {
  const secretKey = crypto.createSecretKey(
    Buffer.from(process.env.SECRET, "hex")
  );

  return await new EncryptJWT({ id })
    .setProtectedHeader({ alg: "dir", enc: "A256GCM" })
    .setIssuedAt()
    .setExpirationTime("14d")
    .encrypt(secretKey);
};  
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda