Acro
Acro
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Acro on 10/8/2024 in #questions
T3 Env: Unconventional Setup: SvelteKit + Payload CMS
Turborepo 1. Frontend: SvelteKit - Node Adapter > build artifact in backend folder 2. Backend: Payload CMS v3 - Next.js Custom Express Server -> /admin route handled by Next.js, all other routes handled by handler.js build artifact by SvelteKit. Running backend dev (Next.js) admin - no ENV issues. It has its own .env on its root. Frontend running dev - Importing my payload.config.ts from backend to SvelteKit to make local API calls gives Required issue on all ENV variables. Meaning it isn't detecting any ENV variables. I have a .env file in root of SvelteKit. console.log() env variables and they show up. SvelteKit file that reaches outside of its project folder to get payload.config.ts from backend. The payload.config.ts references the env.MY_VARIABLE
import { type BasePayload, getPayload } from 'payload';
import config from '../../../backend/src/payload.config'

let payloadInstance: BasePayload;

export async function initializePayload() {
payloadInstance = await getPayload({ config })
}
import { type BasePayload, getPayload } from 'payload';
import config from '../../../backend/src/payload.config'

let payloadInstance: BasePayload;

export async function initializePayload() {
payloadInstance = await getPayload({ config })
}
My createEnv is at backend/src/env.ts How do I get @t3-oss/env-core to find env files like this? @t3-oss/env-core is only installed on backend. Do I need it in frontend (SvelteKit) as well? Just tried this, didn't work...
2 replies