28 lines
973 B
TypeScript
28 lines
973 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
|
|
const url = target ? new URL(target) : null
|
|
if (!url || url.protocol !== 'http:' || url.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), {
|
|
// Loopback even when started by hand: the proxy carries the trial account's session.
|
|
server: {
|
|
host: '127.0.0.1',
|
|
strictPort: true,
|
|
proxy: Object.fromEntries(
|
|
SUPABASE_ROUTES.map((route) => [route, { target }]),
|
|
),
|
|
},
|
|
}),
|
|
)
|