Closed hartmut-co-uk closed 3 years ago
v1.4.0
https://codesandbox.io/s/awesome-sanderson-vijy1
console.log server Terminal
/home | fetch() | from server /home | fetch() | process.env.TEST1 TEST1 /home | fetch() | context.env.TEST1 undefined /home | fetch() | process.env.TEST2 TEST2 /home | fetch() | context.env.TEST2 TEST2 /home | fetch() | process.env.TEST3 undefined /home | fetch() | context.env.TEST3 undefined
console.log client Console (toggle route '/about' <> '/')
/home | fetch() | from client /home | fetch() | process.env.TEST1 undefined /home | fetch() | context.env.TEST1 undefined /home | fetch() | process.env.TEST2 TEST2 /home | fetch() | context.env.TEST2 TEST2 /home | fetch() | process.env.TEST3 undefined /home | fetch() | context.env.TEST3 undefined
/home | fetch() | from server /home | fetch() | process.env.TEST1 undefined /home | fetch() | context.env.TEST1 undefined /home | fetch() | process.env.TEST2 TEST2 /home | fetch() | context.env.TEST2 TEST2 /home | fetch() | process.env.TEST3 undefined /home | fetch() | context.env.TEST3 undefined
I'd expect to have control over environment variables visibility via 'only' option.
E.g. with .env file
.env
STRIPE_SECRET_KEY="1234" STRIPE_PUBLISHABLE_KEY="9876"
and configuring ['@nuxtjs/dotenv', { only: ['STRIPE_PUBLISHABLE_KEY'] }] both variables should be available server-side - while client-side only STRIPE_PUBLISHABLE_KEY should be accessible.
['@nuxtjs/dotenv', { only: ['STRIPE_PUBLISHABLE_KEY'] }]
STRIPE_PUBLISHABLE_KEY
Closing in favour of using the runtimeConfig, here it is better to specify them in privateRuntimeConfig instead of using only.
privateRuntimeConfig
only
See https://nuxtjs.org/blog/moving-from-nuxtjs-dotenv-to-runtime-config#migrating-to-the-nuxtjs-runtime-config-from-nuxtjsdotenv
Version
v1.4.0
Reproduction link
https://codesandbox.io/s/awesome-sanderson-vijy1
Steps to reproduce
What is expected ?
console.log server Terminal
console.log client Console (toggle route '/about' <> '/')
What is actually happening?
console.log server Terminal
console.log client Console (toggle route '/about' <> '/')
Additional comments?
I'd expect to have control over environment variables visibility via 'only' option.
E.g. with
.env
fileand configuring
['@nuxtjs/dotenv', { only: ['STRIPE_PUBLISHABLE_KEY'] }]
both variables should be available server-side - while client-side onlySTRIPE_PUBLISHABLE_KEY
should be accessible.