videogen/apps/web/next.config.mjs
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

169 lines
9.1 KiB
JavaScript

import path from "node:path";
// Built from what the app actually loads (grepped + live-verified, not guessed):
// Clerk Frontend API is the custom domain clerk.menivor.com (no proxy configured
// -- NEXT_PUBLIC_CLERK_PROXY_URL is unset in wrangler.jsonc, see lib/clerk.ts);
// Turnstile (components/marketing/reel-preview/Turnstile.tsx) loads from
// challenges.cloudflare.com; browser fetches go to api.menivor.com
// (NEXT_PUBLIC_API_BASE); GlitchTip browser error reporting posts to
// errors.ereboslab.com (src/shared/observability/glitchtip.ts); Railyard
// Insights (lib/track.ts) is injected as a <script src="https://insights.ereboslab.com/s.js">
// tag at the edge by railyard/apps/insights-edge, not rendered by this repo, so
// it still needs a CSP allowance; X conversion tracking (app/layout.tsx) loads
// static.ads-twitter.com and reports to analytics.twitter.com/t.co; "Made with
// Menivor" video posters/media stream from media.menivor.com; the free
// in-browser AI tools (components/marketing/free-tools/browser-workers.ts) load
// Transformers.js/Kokoro from cdn.jsdelivr.net as Blob module workers, which in
// turn fetch model weights from huggingface.co/hf.co; components/design/fonts.ts
// injects Google Fonts <link>s at runtime. Two more confirmed via a live
// headless-browser console check (2026-11-17), not just static grep: the
// Cloudflare zone's own Web Analytics beacon (a zone-level setting, not
// anything this repo renders) loads static.cloudflareinsights.com, and the
// footer's "Featured on FoundrList" badge (same pattern already fixed on
// bidstage.app) loads foundrlist.com -- both were real CSP violations in
// this header set's first deploy and are allowed below. One more confirmed
// live 2026-11-17 via the 390px mobile paste-a-link flow: the free reel
// preview's "hook frame" for an App Store or Play Store link
// (apps/api/.../reel_preview/service.py renders the listing's own
// screenshot/icon straight into an <img src=...>) pointed at Apple's
// *.mzstatic.com CDN or Google's play-lh.googleusercontent.com, both
// silently CSP-blocked -- every app/play link preview rendered its hook
// text with no proof frame at all. Allowed below so the preview's single
// most convincing element (a real screenshot) actually shows.
const securityHeaders = [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
{
key: "Content-Security-Policy",
value:
"default-src 'self'; " +
"script-src 'self' 'unsafe-inline' https://challenges.cloudflare.com https://static.ads-twitter.com https://insights.ereboslab.com https://cdn.jsdelivr.net https://clerk.menivor.com https://static.cloudflareinsights.com; " +
"script-src-attr 'none'; " +
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " +
"img-src 'self' data: blob: https://media.menivor.com https://analytics.twitter.com https://t.co https://img.clerk.com https://clerk.menivor.com https://foundrlist.com https://*.mzstatic.com https://play-lh.googleusercontent.com; " +
"media-src 'self' https://media.menivor.com; " +
"connect-src 'self' https://api.menivor.com https://challenges.cloudflare.com https://insights.ereboslab.com https://errors.ereboslab.com https://analytics.twitter.com https://t.co https://clerk.menivor.com https://cdn.jsdelivr.net https://huggingface.co https://*.hf.co https://cloudflareinsights.com; " +
"font-src 'self' https://fonts.gstatic.com data:; " +
"worker-src 'self' blob:; " +
"frame-src https://challenges.cloudflare.com; " +
"manifest-src 'self'; " +
"form-action 'self' https://dodopayments.com https://*.dodopayments.com; " +
"frame-ancestors 'none'; " +
"base-uri 'self'; " +
"object-src 'none'; " +
"upgrade-insecure-requests",
},
];
// The OTT embed page (app/(ott)/embed/[id]/page.tsx) is an oEmbed iframe
// target meant to be framed by arbitrary third-party sites -- the global
// frame-ancestors 'none' above would break it. This CSP (defined after the
// generic "/:path*" entry in headers() below, so it wins per Next's
// last-match-per-key rule) explicitly allows framing by anyone; per the CSP
// spec, a present frame-ancestors directive makes browsers ignore the
// inherited X-Frame-Options: DENY, so no separate XFO override is needed.
const embedHeaders = [
{
key: "Content-Security-Policy",
value:
"default-src 'self'; img-src 'self' data: blob: https://media.menivor.com; " +
"media-src 'self' https://media.menivor.com; connect-src 'self' https://api.menivor.com; " +
"style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; " +
"frame-ancestors *; base-uri 'self'; object-src 'none'",
},
];
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// Wave P PM2.5: the OTT player core ships as TypeScript source in packages/ott-player.
transpilePackages: ["@menivor/ott-player"],
// Deploys to Cloudflare Workers via @opennextjs/cloudflare, which consumes
// Next's standalone server output.
output: "standalone",
// Trace from the monorepo root so hoisted workspace deps (notably `next`
// itself, which npm hoists to the root node_modules) are fully copied into
// the standalone bundle. This nests the output under `apps/web/`, which
// OpenNext resolves via packagePath once it detects the monorepo root.
outputFileTracingRoot: path.resolve(process.cwd(), "../.."),
// Image Optimization API is unsupported on the Workers runtime; serve images
// unoptimized and allow remote avatar/preview thumbnails from any HTTPS origin.
images: {
unoptimized: true,
remotePatterns: [{ protocol: "https", hostname: "**" }],
},
// Surface the API base at build time for the typed client in lib/api.ts.
env: {
NEXT_PUBLIC_API_BASE:
process.env.NEXT_PUBLIC_API_BASE || "http://localhost:8080/api/v1",
},
// Retired marketing URLs. `permanent: true` answers 308 so search engines
// move the old URL's signal to the new page.
async redirects() {
const home = "/";
return [
{ source: "/wolfcut", destination: "/editor", permanent: true },
{ source: "/wolfcut/:path*", destination: "/editor", permanent: true },
{ source: "/compare", destination: home, permanent: true },
{ source: "/compare/:path*", destination: home, permanent: true },
{ source: "/vs/:path*", destination: home, permanent: true },
{ source: "/alternatives", destination: home, permanent: true },
{ source: "/alternatives/:path*", destination: home, permanent: true },
{ source: "/pricing/compare", destination: "/pricing", permanent: true },
{ source: "/templates", destination: "/create", permanent: true },
{ source: "/templates/:path*", destination: "/create", permanent: true },
// Guessable / legacy URLs that 404'd: send people to the real page.
{ source: "/videos", destination: "/reels", permanent: true },
{ source: "/videos/:id", destination: "/reels/:id", permanent: true },
{ source: "/results", destination: "/reels", permanent: true },
{ source: "/help", destination: "/contact", permanent: true },
{ source: "/support", destination: "/contact", permanent: true },
{ source: "/legal", destination: "/terms", permanent: true },
{ source: "/legal/terms", destination: "/terms", permanent: true },
{ source: "/legal/privacy", destination: "/privacy", permanent: true },
{ source: "/legal/refunds", destination: "/refunds", permanent: true },
{ source: "/acceptable-use", destination: "/legal/acceptable-use", permanent: true },
{ source: "/aup", destination: "/legal/acceptable-use", permanent: true },
// llms.txt discoverability: common alternate paths AI crawlers probe for.
{ source: "/llm.txt", destination: "/llms.txt", permanent: true },
{ source: "/LLMs.txt", destination: "/llms.txt", permanent: true },
{ source: "/llms", destination: "/llms.txt", permanent: true },
{ source: "/.well-known/llms.txt", destination: "/llms.txt", permanent: true },
{ source: "/llm-full.txt", destination: "/llms-full.txt", permanent: true },
{ source: "/.well-known/llms-full.txt", destination: "/llms-full.txt", permanent: true },
];
},
async headers() {
const privatePrefixes = [
"/account",
"/admin",
"/billing",
"/connections",
"/dashboard",
"/insights",
"/new",
"/reels",
"/settings",
"/studio",
"/wallet",
"/workspace",
];
return [
{ source: "/:path*", headers: securityHeaders },
...privatePrefixes.map((source) => ({
source: `${source}/:path*`,
headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow" }],
})),
// Defined last so its Content-Security-Policy wins over the generic
// "/:path*" entry above for this one route (see embedHeaders comment).
{ source: "/embed/:path*", headers: embedHeaders },
];
},
};
export default nextConfig;