import type { NextConfig } from "next";

/**
 * Sub-path hosting: in production the app is served under `/rankora`
 * (e.g. clawstechnologies.com/rankora). Set `NEXT_PUBLIC_BASE_PATH=/rankora`
 * in the production env so Next prefixes EVERY link and asset with it —
 * otherwise internal links resolve to the domain root and 404. Left unset in
 * local dev so the app runs at `/`.
 */
const basePath = process.env.NEXT_PUBLIC_BASE_PATH?.replace(/\/$/, "") || "";

const nextConfig: NextConfig = {
  // better-sqlite3 is a native addon — keep it external so the server bundle
  // requires it at runtime instead of trying to bundle the .node binary.
  serverExternalPackages: ["better-sqlite3"],
  ...(basePath ? { basePath, assetPrefix: basePath } : {}),
};

export default nextConfig;
