fix(supabase): LAN trial answers its own host only, guide matches lot O
This commit is contained in:
1 parent
060ee50464
commit
5207f87e66
3 files changed
+29
-8
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { defineConfig, mergeConfig } from 'vite'
|
||||
import { defineConfig, mergeConfig, type Plugin } from 'vite'
|
||||
import base from '../vite.config'
|
||||
|
||||
/**
|
||||
@@ -27,8 +27,25 @@ if (!PRIVATE_IPV4.test(host))
|
||||
const SUPABASE_ROUTES = ['/auth/v1', '/rest/v1', '/storage/v1']
|
||||
const REPO = fileURLToPath(new URL('../../../', import.meta.url))
|
||||
|
||||
/**
|
||||
* `allowedHosts` still lets every IP literal and localhost through (Vite 7):
|
||||
* any Host other than the trial host gets a 403.
|
||||
*/
|
||||
const trialHostOnly: Plugin = {
|
||||
name: 'faunosteo-trial-host-only',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
const name = (req.headers.host ?? '').replace(/:\d+$/, '')
|
||||
if (name === host) return next()
|
||||
res.statusCode = 403
|
||||
res.end()
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export default defineConfig((env) =>
|
||||
mergeConfig(base(env), {
|
||||
plugins: [trialHostOnly],
|
||||
// One validated host, never 0.0.0.0: the proxy carries the trial account's session.
|
||||
server: {
|
||||
host,
|
||||
|
||||
Reference in new issue
Block a user