Files
faunosteo/apps/app/vite/trial.config.ts
T

24 lines
777 B
TypeScript

import { defineConfig, mergeConfig } from 'vite'
import base from '../vite.config'
/**
* Dev server of `pnpm db:sandbox trial` (docs/development/V1-2-6_OWNER_TRIAL.md).
* The browser talks to this origin only: the three Supabase routes are
* forwarded to the trial gateway on loopback, so no CORS rule is involved.
*/
const target = process.env.FAUNOSTEO_TRIAL_GATEWAY
if (!target || new URL(target).hostname !== '127.0.0.1')
throw new Error('FAUNOSTEO_TRIAL_GATEWAY must be an http://127.0.0.1:<port> URL')
const SUPABASE_ROUTES = ['/auth/v1', '/rest/v1', '/storage/v1']
export default defineConfig((env) =>
mergeConfig(base(env), {
server: {
proxy: Object.fromEntries(
SUPABASE_ROUTES.map((route) => [route, { target }]),
),
},
}),
)