Allow any dev server host via ALLOWED_HOSTS env var

This commit is contained in:
Alex Gleason
2026-04-06 14:38:12 -05:00
parent 2ecd557430
commit cbc3df0bef
2 changed files with 8 additions and 3 deletions
+3 -1
View File
@@ -2,4 +2,6 @@ VITE_SENTRY_DSN="https://********************************@*****************.exam
VITE_PLAUSIBLE_DOMAIN="example.tld"
VITE_PLAUSIBLE_ENDPOINT="https://plausible.example.tld/api/event"
# Hex pubkey of the nostr-push server (found in nostr-push startup logs as "worker_pubkey")
VITE_NOSTR_PUSH_PUBKEY=""
VITE_NOSTR_PUSH_PUBKEY=""
# Set to "*" to allow any host in the Vite dev server (eg. when proxying through a custom domain)
# ALLOWED_HOSTS="*"
+5 -2
View File
@@ -6,7 +6,7 @@ import path from "node:path";
import react from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig, type Plugin } from "vite";
import { defineConfig, loadEnv, type Plugin } from "vite";
import { DittoConfigSchema } from "./src/lib/schemas";
@@ -120,11 +120,14 @@ function getCommitTag(): string {
}
// https://vitejs.dev/config/
export default defineConfig(() => {
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
server: {
host: "::",
port: 8080,
allowedHosts: env.ALLOWED_HOSTS === "*" ? true : undefined,
},
plugins: [
react(),