fix(supabase): LAN trial closes every upgrade socket, guide on CORS

This commit is contained in:
bchanot committed 2026-11-04 23:43:15 +01:00
1 parent b2941ebcb2
commit 72b742f9d3
2 files changed
+11 -3

No files matched your search

+7
View File
@@ -30,10 +30,17 @@ const REPO = fileURLToPath(new URL('../../../', import.meta.url))
/**
* `allowedHosts` still lets every IP literal and localhost through (Vite 7): any HTTP request
* whose Host is not the trial host gets a 403, and the editor-launch route is closed to the LAN.
* The trial serves no WebSocket: the proxy's upgrade listener would hold such a socket open, so
* every upgrade is closed at once.
*/
const trialHostOnly: Plugin = {
name: 'faunosteo-trial-host-only',
configureServer(server) {
server.httpServer?.on('upgrade', (_req, socket) => socket.destroy())
server.middlewares.use('/__open-in-editor', (_req, res) => {
res.statusCode = 404
res.end()
})
server.middlewares.use((req, res, next) => {
const name = (req.headers.host ?? '').replace(/:\d+$/, '')
const launch = (req.url ?? '').toLowerCase().includes('/__open-in-editor')