#useRuntimeConfig vs process.env in api routes

1 messages · Page 1 of 1 (latest)

ebon chasm
#

Hello, i'm having trouble wrapping my hear around this.

I know that variables in my .env are accessible using useRuntimeConfig() and also through process.env, is there a preferred approach for serverside api routes?
Is there a difference at all?

cloud hedge
ebon chasm
# cloud hedge See also https://youtu.be/_FYV5WfiWvs

in the video, you're using $config in a template and using process.env in the nuxt.config public runtime configuration. You show that the only way to actually change the public variable 'myValue' during runtime, is by defining 'NUXT_PUBLIC_MY_VALUE'

so from what I've understood, by using process.env directly in an api route, i won't have the ability to change the value during runtime, since the NUXT_MY_VALUE property wouldn't even be available due to not using runtimeConfig/useRuntimeConfig()/$config in the first place, is that correct?

cloud hedge
tender cypress
cloud hedge
tender cypress
#

Appreciate your help to community! Means a lot!

cloud hedge
cloud hedge
tender cypress
cloud hedge
#

What kind of key is it if I may ask?

#

Like, which service

tender cypress
cloud hedge
tender cypress