-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
43 lines (36 loc) · 1.03 KB
/
next.config.ts
File metadata and controls
43 lines (36 loc) · 1.03 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
import type { NextConfig } from "next";
import type { RemotePattern } from "next/dist/shared/lib/image-config";
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
// Function to parse domains from environment variable
const getRemotePatterns = () => {
const patterns: Array<{
protocol: RemotePattern["protocol"];
hostname: RemotePattern["hostname"];
}> = [];
// Add extra domains via env (comma-separated)
// Ex: NEXT_PUBLIC_ALLOWED_DOMAINS=example.com,cdn.example.com
const extraDomains =
process.env.NEXT_PUBLIC_ALLOWED_DOMAINS?.split(",") || [];
extraDomains.forEach((domain) => {
const trimmedDomain = domain.trim();
if (trimmedDomain) {
patterns.push({
protocol: "https" as const,
hostname: trimmedDomain,
});
}
});
return patterns;
};
const nextConfig: NextConfig = {
// output: "standalone",
basePath: basePath,
images: {
remotePatterns: getRemotePatterns(),
},
typedRoutes: true,
experimental: {
typedEnv: true,
},
};
export default nextConfig;