t3-oss / t3-env

https://env.t3.gg
MIT License
2.78k stars 86 forks source link

SvelteKit + @sveltejs/adapter-node = "Attempted to access a server-side environment variable on the client" #251

Closed arkmech closed 4 months ago

arkmech commented 4 months ago
  1. In, svelte.config.js, using @sveltejs/adapter-node as adapter.
  2. Run vite build, generates build directory with SvelteKit handlers
  3. @t3-oss/env-core ./src/env.ts, where createEnv is setup.
  4. Two places use env.ts: ./src/lib/server/index.ts (express server) and ./src/lib/server/payload/payload.config.ts,
  5. Run using cross-env PAYLOAD_CONFIG_PATH=./src/payload.config.ts tsx watch ./src/lib/server/index.ts

I have just had lots of issues doing this an example repo would be nice.