I want to access env variables in a composable written in nuxt2 (not 3!) together with the composition-api plugin.
How can I do that?
This approach to use useRuntimeConfig probably only works with nuxt 3: How to access environment variables in a composable in Nuxt3?
I tried to use useContext and in there I see that the returned object by doing
import {useContext} from '@nuxtjs/composition-api'
...
const context = useContext()
includes a key env. But this env key only contains the env variables defined in the nuxt config.
env: {
BACKEND_URL: process.env.BACKEND_URL,
}
So I could access it by context.env.BACKEND_URL...
Is this right approach? How could I get just all the content of my .env file, which I can do in the options API by using process.env?