https://github.com/captaincodeman/svelte-kit-10008
https://github.com/captaincodeman/svelte-kit-10008
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/captaincodeman/svelte-kit-10008
- Owner: CaptainCodeman
- Created: 2023-05-22T15:19:11.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-26T17:25:54.000Z (over 2 years ago)
- Last Synced: 2025-05-07T04:37:49.077Z (9 months ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Example
Reproduction for [https://github.com/sveltejs/kit/issues/10008](https://github.com/sveltejs/kit/issues/10008)
Run `pnpm dev`, the expected `PUBLIC_API_KEY: my-personal-key-for-dev-only` appears on all pages.
Run `pnpm build` to compile with the Node adapter, then `pnpm start` to execute with a dynamic `.env` value. Initially the value is correct (`PUBLIC_API_KEY: proper-public-key`), but landing on the pre-rendered page (goto `http://localhost:3000/prerendered` and refresh) switches it to incorrectly use the dev-mode `.env` value for that and all subsequent pages.
The pre-rendered page has the dev mode `.env` value embedded, effectively changing it to be a static value. This can break the app and risks exposing something that wasn't _intended_ to be made public (despite it being a public variable).
```html
{
__sveltekit_o5vefy = {
base: new URL(".", location).pathname.slice(0, -1),
env: {"PUBLIC_API_KEY":"my-personal-key-for-dev-only"}
};
```