Every page reads the Sokko TCG configuration and reserve, and a fast browser test run loads more than 120 pages a minute from a single address, so the dev server answered 429. The dev server is local and already gives admin rights to any visitor, so it now lifts the per-minute limits like the Cards test server. The production server keeps them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.5 KiB
JavaScript
44 lines
1.5 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) {
|
|
// Chaque page lit la configuration et la réserve : la suite E2E, depuis une seule adresse, dépasserait la limite par minute de production.
|
|
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: process.env.CARDS_ENABLED !== "false", devAuth: process.env.CARDS_DEV_AUTH !== "false", devPerks: true, apiRateLimit: 100_000 });
|
|
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
|
|
}
|
|
});
|