Using environment variables for apollo client httpEndpoint #495
-
Having issue setting httpEndpoint to an environment variable. The docs only give an example of setting using a string but process.env.VITE_API_URL seems to be undefined and import.meta is not allowed outside of modules. Any suggestions on how to fix this or what is the proper way to use this with environment. Examples I found uses clientConfig property which is not allowed on apollo property or use a plugin method.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Well basically just add this and was fine. |
Beta Was this translation helpful? Give feedback.
Well basically just add this and was fine.
export default defineNuxtConfig({
....
apollo: {
clients: {
default: {
httpEndpoint: process.env.VITE_API_URL || 'localhost:8000/graphql'
},
},
....
vite: {
envDir: "../..",
},
});