morteza mortezaie
morteza mortezaie

Reputation: 1564

Nuxt 3 Runtime config values are not replaced by env variables

I'm using Nuxt 3

i have .env like this

NUXT_CAPTCHA_KEY=123456

and this is nuxt.config.ts

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      captchaKey: 'some value',
    }
  },
});

and in my component login.vue

I want to use Recaptcha like this

function login() {
  const config = useRuntimeConfig()
  console.log('config', config.public.captchaKey);
}

I think it must print '123456' in console

as it said in document

but it doesn't.

and it prints 'some value'

why is that ?

Upvotes: 1

Views: 3029

Answers (1)

yoduh
yoduh

Reputation: 14649

captchaKey is public so the .env key must be named NUXT_PUBLIC_CAPTCHA_KEY

Upvotes: 6

Related Questions