forked from Twixes/rfc123
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
71 lines (64 loc) · 2.2 KB
/
Copy pathnext.config.ts
File metadata and controls
71 lines (64 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { withPostHogConfig } from "@posthog/nextjs-config";
import type { NextConfig } from "next";
// Rewrite to the assets host matching NEXT_PUBLIC_POSTHOG_HOST so a US
// self-hoster doesn't silently proxy through eu.i.posthog.com.
const POSTHOG_HOST =
process.env.NEXT_PUBLIC_POSTHOG_HOST ?? "https://us.i.posthog.com";
const POSTHOG_ASSETS_HOST = POSTHOG_HOST.startsWith("https://eu.")
? "https://eu-assets.i.posthog.com"
: "https://us-assets.i.posthog.com";
const nextConfig: NextConfig = {
/* config options here */
reactCompiler: true,
// Required for the Docker image: emits a self-contained `.next/standalone`
// bundle that runs without node_modules in the runtime layer.
output: "standalone",
// Map GitHub-style PR URLs (/:owner/:repo/pull/:number) to our RFC routes
// so people can swap github.com for rfc123.com and land on the right page.
async redirects() {
return [
{
source: "/:owner/:repo/pull/:number(\\d+)",
destination: "/rfcs/:owner/:repo/:number",
permanent: false,
},
{
source: "/:owner/:repo/pull/:number(\\d+)/:rest*",
destination: "/rfcs/:owner/:repo/:number",
permanent: false,
},
];
},
// Rewrites to support PostHog ingestion endpoints
async rewrites() {
return [
{
source: "/ingest/static/:path*",
destination: `${POSTHOG_ASSETS_HOST}/static/:path*`,
},
{
source: "/ingest/array/:path*",
destination: `${POSTHOG_ASSETS_HOST}/array/:path*`,
},
{
source: "/ingest/:path*",
destination: `${POSTHOG_HOST}/:path*`,
},
];
},
// Required to support PostHog trailing slash API requests
skipTrailingSlashRedirect: true,
};
// Only upload source maps when a personal API key is present (i.e. on Vercel
// deploys). Local `pnpm build` runs are no-ops, which keeps dev unblocked.
export default process.env.POSTHOG_PERSONAL_API_KEY
? withPostHogConfig(nextConfig, {
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
projectId: process.env.POSTHOG_PROJECT_ID ?? "",
host: POSTHOG_HOST,
sourcemaps: {
enabled: true,
deleteAfterUpload: true,
},
})
: nextConfig;