sokko-g/vite.config.js
Shinuwa 9ce0c3e33a
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 19m52s
Validate and deploy Sokko G / deploy (push) Successful in 10s
Tighten the remaining Cards and dev server security defaults
Session and OAuth cookies now carry the __Host- prefix over HTTPS, so another
application of the domain cannot set them. The public configuration route has
a request limit, the trader list reads every player in one query, and new
campaign codes need eight characters while existing ones keep working.

The Vite server now listens on 127.0.0.1 unless HOST says otherwise, because
it gives administrator rights to any visitor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 14:27:22 +01:00

43 lines
1.3 KiB
JavaScript

// Rôle : configure Vite et charge les variables locales communes au serveur.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { loadProjectEnv } from "./scripts/load-project-env.mjs";
import { createCardsApiHandler } from "./services/cards/api.js";
import { resolve } from "node:path";
loadProjectEnv();
// Le serveur de développement donne les droits administrateur à tout visiteur : il reste local sauf demande explicite.
const devHost = process.env.HOST || "127.0.0.1";
function nebulaCardsApi() {
return {
name: "nebula-cards-api",
apply: "serve",
configureServer(server) {
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: process.env.CARDS_ENABLED !== "false", devAuth: process.env.CARDS_DEV_AUTH !== "false", devPerks: true });
server.middlewares.use(async (req, res, next) => {
if (!await handler(req, res)) next();
});
server.httpServer?.once("close", handler.close);
}
};
}
export default defineConfig({
root: "website",
publicDir: "public",
plugins: [react(), nebulaCardsApi()],
server: {
host: devHost,
port: Number(process.env.PORT || 5173)
},
preview: {
host: devHost,
port: Number(process.env.PORT || 4173)
},
build: {
outDir: "dist",
emptyOutDir: true
}
});