metatron-open-seo/vite.config.ts
metatroncubeswdev 1146dc2f6a
Some checks failed
CI / ci (push) Has been cancelled
CI / docker-build (push) Has been cancelled
Publish Docker image / docker (push) Has been cancelled
Upload sourcemaps / upload (push) Has been cancelled
vite.config.ts: actually read PORT/ALLOWED_HOST from env
Both were documented self-host knobs (SELF_HOSTING_DOCKER.md, compose.yaml)
but hardcoded to port 3001 and seo.thedomainnest.com instead, so any second
instance on a different port/domain got either a port clash or Vite's
preview host-check ("Blocked request... not allowed"). Defaults preserve
exact current behavior for deployments that don't set these.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-17 19:49:21 -04:00

85 lines
2.0 KiB
TypeScript

import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { defineConfig } from "vite";
import tsConfigPaths from "vite-tsconfig-paths";
import viteReact from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { cloudflare } from "@cloudflare/vite-plugin";
import { devtools } from "@tanstack/devtools-vite";
import { leanWorkerBundle } from "./vite-plugin-lean-worker-bundle";
export default defineConfig(() => {
// PORT/ALLOWED_HOST are documented self-host knobs (SELF_HOSTING_DOCKER.md,
// compose.yaml) but were never actually read here — every deployment was
// silently stuck on port 3001 and this one hardcoded domain, breaking any
// second instance on a different domain or port. Defaults keep existing
// deployments that don't set these working exactly as before.
const port = Number(process.env.PORT) || 3001;
const showDevtools = false;
const allowedHosts = [
"seo.thedomainnest.com",
process.env.ALLOWED_HOST,
].filter((host): host is string => Boolean(host));
return {
envPrefix: [
"VITE_",
"AUTH_MODE",
"BYPASS_EMAIL_VERIFICATION",
"POSTHOG_PUBLIC_KEY",
"POSTHOG_HOST",
"TURNSTILE_SITE_KEY",
"GOOGLE_CLIENT_ID",
],
server: {
host: "0.0.0.0",
port,
allowedHosts,
},
preview: {
host: "0.0.0.0",
port,
allowedHosts,
},
build: {
sourcemap: false,
outDir: "dist",
},
plugins: [
leanWorkerBundle(),
showDevtools
? devtools({
consolePiping: {
enabled: true,
levels: ["log", "warn", "error", "info", "debug"],
},
})
: null,
cloudflare({
inspectorPort: false,
viteEnvironment: { name: "ssr" },
auxiliaryWorkers: [
{
configPath: "./wrangler.audit.jsonc",
},
],
}),
tsConfigPaths(),
tanstackStart(),
viteReact(),
tailwindcss(),
],
};
});