ข้ามไปที่เนื้อหา

Vite (SvelteKit)

Set web environment variables for local and production.

3 min read

Connect your agent today

Draft from chat, review in your calendar, and publish only what you approve.

เริ่มใช้งานฟรี

Overview

The web app is built with SvelteKit on Vite. At runtime it reads public env vars in the VITE_* family from web/.env.* (Vite loads these at dev and build time).

When you change values in web/.env.development.local or web/.env.production.local, restart the web dev server or rebuild so Vite can load the new values.

Steps

Copy the development env template

Copy web/.env.development.example to web/.env.development.local.

Set required variables

Set these in web/.env.development.local (values from your backend, Supabase, Stripe, and analytics setup):

VITE_API_BASE_URL=
VITE_FRONTEND_DOMAIN_URL=
VITE_PUBLIC_SUPABASE_URL=
VITE_PUBLIC_STRIPE_PUBLISHABLE_KEY=
VITE_PUBLIC_STRIPE_PRICE_ID_SOLO_MONTHLY=
VITE_PUBLIC_STRIPE_PRICE_ID_SOLO_YEARLY=
VITE_PUBLIC_STRIPE_PRICE_ID_TEAM_MONTHLY=
VITE_PUBLIC_STRIPE_PRICE_ID_TEAM_YEARLY=
VITE_PUBLIC_STRIPE_PRICE_ID_ULTIMATE_MONTHLY=
VITE_PUBLIC_STRIPE_PRICE_ID_ULTIMATE_YEARLY=
VITE_PUBLIC_STRIPE_PRICE_ID_MAX_MONTHLY=
VITE_PUBLIC_STRIPE_PRICE_ID_MAX_YEARLY=
VITE_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID=

HTTPS local development and the API base URL

The web dev server in this repo uses HTTPS on https://localhost:5173 (local certificates under web/.cert/). Session cookies for sign-in must be issued on the same site as the page origin, so the browser should call the API as same-origin /api/… in development, not a separate http://localhost:3000 origin.

In development, web/src/hooks.server.ts forwards /api/* to the process listening on http://localhost:3000 (see web/vite.config.ts for the same target). Optional override: set DEV_BACKEND_PROXY_TARGET in web/.env.development.local if the API is not on port 3000.

Set production env values

For deployment, ensure web/.env.production.local (or your host’s production env) sets the same key names with production values. Double-check VITE_FRONTEND_DOMAIN_URL against FRONTEND_DOMAIN_URL on the API before you register OAuth redirect URIs in external dashboards.

Stripe subscription price ids are configured on the web (VITE_PUBLIC_STRIPE_PRICE_ID_SOLO_MONTHLY, and so on). See Stripe billing.

ค้นหาเอกสาร
ค้นหาหน้าเอกสาร
ศูนย์ช่วยเหลือ