Reputation: 1001
I'am using the new SvelteKit Framework with the node-adapter
and i have a problem of undefined
Environment-Variables when using process.env.APPLICATION_KEY_ID
Syntax in an endpoint in production build.
When i use:
console.log(process.env)
i'am getting a list of all variables, including my APPLICATION_KEY_ID
ALLUSERSPROFILE: 'C:\\ProgramData',
APPDATA: 'C:\\Users\\user\\AppData\\Roaming',
APPLICATION_KEY_ID: 'test',
But when i use console.log(process.env.APPLICATION_KEY_ID)
i'am getting undefined
Can someone give me a hint what i'am doing wrong?
I'am running the app in kubernetes, this is my Dockerfile for building this image:
# build the sapper app
FROM mhart/alpine-node:14 AS build
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
# install dependencies
FROM mhart/alpine-node:14 AS deps
WORKDIR /app
COPY package.json .
COPY --from=build /app/package-lock.json package-lock.json
RUN npm ci --prod
COPY --from=build /app/build build
COPY --from=build /app/node_modules node_modules
# copy node_modules/ and other build files over
FROM mhart/alpine-node:slim-14
WORKDIR /app
COPY --from=deps /app .
EXPOSE 3000
CMD ["node", "build"]
ENV HOST=0.0.0.0
Upvotes: 2
Views: 2561
Reputation: 16411
SvelteKit uses Vite as it's bundler. It is probably best to stick to how this package deals with environment variables. Which is to say, all env variabled prefixed with VITE_
will be available in your code using import.meta.env.VITE_xxx
Upvotes: 3