forked from SmartDropLabs/smartdrop-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
68 lines (62 loc) · 2.07 KB
/
Copy pathnext.config.ts
File metadata and controls
68 lines (62 loc) · 2.07 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
import type { NextConfig } from "next";
import withBundleAnalyzer from "@next/bundle-analyzer";
import { validateEnv } from "./src/config/validateEnv";
validateEnv();
const raw = process.env.BASE_PATH?.trim() ?? "";
const basePath = raw.startsWith("/") ? raw : raw ? `/${raw}` : "";
/**
* NEXT_EXPORT=true → static export for GitHub Pages (no API routes).
* Unset (default) → server mode for Vercel / `next start` (API routes active).
*
* The /api/stats route caches TVL data server-side every 60 s.
* When running in static-export mode the frontend hook falls back to querying
* the Stellar Horizon API directly from the browser.
*/
const isStaticExport = process.env.NEXT_EXPORT === "true";
const backendApiOrigin = (() => {
try {
return new URL(
process.env.NEXT_PUBLIC_BACKEND_API_URL ?? "http://localhost:4000/api/v1"
).origin;
} catch {
return "http://localhost:4000";
}
})();
const CSP_POLICY = [
"default-src 'self'",
"script-src 'self' 'unsafe-eval' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline'",
`connect-src 'self' https://horizon.stellar.org https://horizon-testnet.stellar.org https://soroban-testnet.stellar.org https://soroban.stellar.org https://stellar.expert ${backendApiOrigin}`,
"img-src 'self' data: https:",
"font-src 'self'",
"frame-src 'none'",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
].join("; ");
const nextConfig: NextConfig = {
reactStrictMode: true,
poweredByHeader: false,
images: {
unoptimized: true,
},
...(isStaticExport ? { output: "export" } : {}),
devIndicators: false,
...(basePath ? { basePath, assetPrefix: basePath } : {}),
headers: async () => [
{
source: "/icon.svg",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
],
},
{
source: "/apple-icon.png",
headers: [
{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" },
],
},
],
};
export default withBundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(nextConfig);
export { CSP_POLICY };