-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
66 lines (63 loc) · 2.24 KB
/
Copy pathnext.config.js
File metadata and controls
66 lines (63 loc) · 2.24 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
/**
* Next.js config for the zkCoins explorer.
*
* Static export only: no server runtime, no server state, no keys.
* The node/API base URL is required at build time — there is no default host.
*/
const baseUrl = process.env.NEXT_PUBLIC_NODE_BASE_URL;
if (typeof baseUrl !== 'string' || baseUrl.length === 0) {
throw new Error(
'NEXT_PUBLIC_NODE_BASE_URL is required at build time (no default). ' +
'Set it to the node/API origin the explorer should read, e.g. https://node.example.com',
);
}
let parsedBaseUrl;
try {
parsedBaseUrl = new URL(baseUrl);
} catch {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL is not a valid absolute URL, got ${JSON.stringify(baseUrl)}`,
);
}
if (parsedBaseUrl.protocol !== 'http:' && parsedBaseUrl.protocol !== 'https:') {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL must use http or https protocol, got ${JSON.stringify(baseUrl)}`,
);
}
// WHATWG rejects empty hosts on http(s) before this check can run.
/* v8 ignore next -- empty http(s) host is a parse failure, not a parsed empty hostname */
if (!parsedBaseUrl.hostname) {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL hostname must be non-empty, got ${JSON.stringify(baseUrl)}`,
);
}
if (parsedBaseUrl.username || parsedBaseUrl.password) {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL must not include userinfo credentials, got ${JSON.stringify(baseUrl)}`,
);
}
if (parsedBaseUrl.search) {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL must not include a query string, got ${JSON.stringify(baseUrl)}`,
);
}
if (parsedBaseUrl.hash) {
throw new Error(
`NEXT_PUBLIC_NODE_BASE_URL must not include a fragment, got ${JSON.stringify(baseUrl)}`,
);
}
/** @type {import('next').NextConfig} */
const nextConfig = {
// Stateless, self-hostable container: pure static assets + client hydration.
// Static export does not support next.config headers(); Referrer-Policy is
// set via <meta name="referrer" content="no-referrer"> in the root layout
// (spec §5.6 defense-in-depth for bearer fragment secrets).
output: 'export',
images: {
unoptimized: true,
},
trailingSlash: true,
// Local monorepo SDK (file:../sdk) is ESM and must be transpiled by Next.
transpilePackages: ['@zkcoins/sdk'],
};
module.exports = nextConfig;