0.1.38 gateway
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
// The console is served from /admin, never from the root, so every asset URL it emits has
|
||||
// to carry that prefix. Vite writes those URLs at build time from `base`, which is why this
|
||||
// is a build setting rather than something the container's nginx can rewrite afterwards.
|
||||
export default defineConfig({
|
||||
base: '/admin/',
|
||||
plugins: [react()],
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
// The console is read on a desk, not over a phone connection, and an operator opening
|
||||
// it usually wants one page. Splitting router and vendor out means the shell and the
|
||||
// page the browser is actually rendering are two small files rather than one large one.
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
vendor: ['react', 'react-dom'],
|
||||
router: ['react-router-dom'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5180,
|
||||
// `npm run dev` against a real gateway. The API and the sign-in form both stay on the
|
||||
// gateway, so the dev server proxies them rather than reimplementing either — which is
|
||||
// what lets the development console use the same cookie and the same session as the
|
||||
// deployed one. ADMIN_PREVIEW=1 go test ./internal/api -run TestAdminPreview serves a
|
||||
// canned gateway on 7777 when there is no real one to point at.
|
||||
proxy: {
|
||||
'/admin/api': {
|
||||
target: process.env.MEMBY_GATEWAY ?? 'http://127.0.0.1:7777',
|
||||
changeOrigin: true,
|
||||
// Server-sent events: without this the dev proxy buffers the notification stream
|
||||
// and nothing arrives until the connection closes.
|
||||
configure: (proxy) => {
|
||||
proxy.on('proxyRes', (proxyRes) => {
|
||||
if (proxyRes.headers['content-type']?.includes('text/event-stream')) {
|
||||
proxyRes.headers['cache-control'] = 'no-cache';
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user