-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnext.config.mjs
More file actions
92 lines (88 loc) · 2.51 KB
/
next.config.mjs
File metadata and controls
92 lines (88 loc) · 2.51 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const configuredPosthogRegion = (
process.env.posthog_region ||
process.env.POSTHOG_REGION ||
"US Cloud"
).toLowerCase();
const useEUPosthog = configuredPosthogRegion.includes("eu");
const posthogIngestHost = useEUPosthog
? "https://eu.i.posthog.com"
: "https://us.i.posthog.com";
const posthogAssetsHost = useEUPosthog
? "https://eu-assets.i.posthog.com"
: "https://us-assets.i.posthog.com";
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
optimizePackageImports: ["lucide-react", "date-fns"],
},
images: {
unoptimized: true,
},
eslint: {
ignoreDuringBuilds: true,
},
skipTrailingSlashRedirect: true,
async headers() {
return [
{
source: "/sw.js",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
{ key: "Service-Worker-Allowed", value: "/" },
],
},
{
source: "/service-worker.js",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
{ key: "Service-Worker-Allowed", value: "/" },
{ key: "Content-Type", value: "application/javascript; charset=utf-8" },
],
},
];
},
async rewrites() {
return [
{
source: "/citizen/:path*",
destination:
process.env.NODE_ENV === "development"
? "http://flask:5001/:path*"
: "/citizen/:path*",
},
// Only proxy specific API routes to external service, not all /api/*
// Most /api/gameplay/* routes are handled by Next.js itself
{
source: "/api/external/:path*",
destination:
process.env.NODE_ENV === "development"
? "http://127.0.0.1:5328/api/:path*"
: "/api/external/:path*",
},
{ source: "/ingest/static/:path*", destination: `${posthogAssetsHost}/static/:path*` },
{ source: "/ingest/:path*", destination: `${posthogIngestHost}/:path*` },
{ source: "/ingest/flags", destination: `${posthogIngestHost}/flags` },
];
},
webpack: (config, { isServer }) => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
},
fallback: {
...config.resolve.fallback,
},
};
if (isServer) {
config.externals = [...(config.externals || []), { konva: "konva", canvas: "canvas" }];
} else {
config.node = {
...config.node,
};
}
return config;
},
};
export default nextConfig;