<p>I'am using the new <a href="https://kit.svelte.dev/docs" rel="nofollow noreferrer">SvelteKit</a> Framework with the <code>node-adapter</code></p>
<p>and i have a problem of <code>undefined</code> Environment-Variables when using <code>process.env.APPLICATION_KEY_ID</code> Syntax in an endpoint in production build.</p>
<p>When i use:
<code>console.log(process.env)</code> i'am getting a list of all variables, including my <code>APPLICATION_KEY_ID</code></p>
<pre><code>ALLUSERSPROFILE: 'C:\\ProgramData',
APPDATA: 'C:\\Users\\user\\AppData\\Roaming',
APPLICATION_KEY_ID: 'test',
</code></pre>
<p>But when i use <code>console.log(process.env.APPLICATION_KEY_ID)</code></p>
<p>i'am getting <code>undefined</code></p>
<p>Can someone give me a hint what i'am doing wrong?</p>
<p>I'am running the app in kubernetes, this is my Dockerfile for building this image:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code># 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</code></pre>
</div>
</div>
</p>

<p>SvelteKit uses <a href="https://vitejs.dev/" rel="nofollow noreferrer">Vite</a> 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 <code>VITE_</code> will be available in your code using <code>import.meta.env.VITE_xxx</code></p>
