Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
What is the best way to use environment variables in Nuxt with Docker

I am trying to use environment variables in my nuxt 2.15.8 project for development and production. First i used .env file and then i saw in the documentation that i can use runTimeConfig as best practice.

So i tried to use:

// nuxt.config.js
export default {
  publicRuntimeConfig: {
    apiUrl: process.env.API_URL,
    bucket: process.env.BUCKET,
  },
  privateRuntimeConfig: {
    passwordEncryptKey: process.env.PASSWORD_ENCRYPT_KEY,
  }
}

And then i my vue files this.$config.apiUrl For publicRuntimeConfig it works and i can see the variables but for privateRuntimeConfig it doesn't work How can i use privateRuntimeConfig in my project? for example i need to use them inside the "methods" property or in the "data" property but without exposing them to the browser? Or should i use some other way instead of privateRuntimeConfig?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

privateRuntimeConfig is only available on the server as explained here: https://nuxtjs.org/docs/configuration-glossary/configuration-runtime-config#privateruntimeconfig

So you can only use it on the server's side, probably not where you think as of right now. At the end, Nuxt is a frontend so you can't really hide the data per-se. Everything that you want to use on the client-side needs to be public.

Otherwise, use some middleware or serverless functions as explained here:

  • https://stackoverflow.com/a/73056685/8816585
  • How to handle secret .env varibales in Nuxt Static Apps built with nuxt generate
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda