Ctrl K
ComunidadGuías…

next.config.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import type { NextConfig } from "next";
import { readFileSync } from "fs";
import { execSync } from "child_process";

const version = JSON.parse(readFileSync("./package.json", "utf8")).version as string;
let commit = "";
try {
  commit = execSync("git rev-parse --short HEAD").toString().trim();
} catch {
  /* not a git checkout (e.g. some CI) — version without a hash is fine */
}

const nextConfig: NextConfig = {
  serverExternalPackages: ["better-sqlite3"],
  // Dev only: next dev refuses /_next requests whose origin is not localhost, so reviewing the app
  // from another machine on the LAN loads a shell with no assets and no HMR. Hosts come from the
  // environment (comma separated) because they are private addresses and this repo is public.
  allowedDevOrigins: (process.env.DEV_ORIGINS ?? "").split(",").map((h) => h.trim()).filter(Boolean),
  // Exposed to the client so the app can show its version + commit (see AppVersion).
  env: { NEXT_PUBLIC_APP_VERSION: version, NEXT_PUBLIC_APP_COMMIT: commit },
};

export default nextConfig;