Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
72 lines (65 loc) · 2.71 KB
/
Copy pathnext.config.ts
File metadata and controls
72 lines (65 loc) · 2.71 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
import type { NextConfig } from 'next';
// Soroban RPC / Horizon endpoints this app talks to directly from the
// browser. NEXT_PUBLIC_SOROBAN_RPC_URL / NEXT_PUBLIC_HORIZON_URL are
// env-configurable (self-hosted RPC is supported), so a static CSP can't
// perfectly enumerate every possible deployment — this covers the public
// Stellar-operated testnet/mainnet endpoints used by default. Self-hosted
// RPC operators must add their own origin here.
const CONNECT_SRC = [
"'self'",
'https://soroban-testnet.stellar.org',
'https://soroban-mainnet.stellar.org',
'https://horizon-testnet.stellar.org',
'https://horizon.stellar.org',
].join(' ');
const CSP = [
"default-src 'self'",
// Next.js's own inlined bootstrap/hydration scripts require 'unsafe-inline';
// a nonce-based CSP would remove this but needs middleware wiring, out of
// scope for this pass — tracked as a follow-up, not a currently-exploited gap.
"script-src 'self' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data:",
"font-src 'self' data:",
`connect-src ${CONNECT_SRC}`,
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
].join('; ');
const nextConfig: NextConfig = {
reactStrictMode: true,
// Required for @stellar/stellar-sdk in Edge / Node environments
serverExternalPackages: ['@stellar/stellar-sdk'],
// Expose only public vars to the browser
env: {
NEXT_PUBLIC_SOROBAN_RPC_URL: process.env.NEXT_PUBLIC_SOROBAN_RPC_URL ?? '',
NEXT_PUBLIC_NETWORK_PASSPHRASE: process.env.NEXT_PUBLIC_NETWORK_PASSPHRASE ?? '',
NEXT_PUBLIC_FACTORY_CONTRACT_ID: process.env.NEXT_PUBLIC_FACTORY_CONTRACT_ID ?? '',
NEXT_PUBLIC_GOVERNOR_CONTRACT_ID: process.env.NEXT_PUBLIC_GOVERNOR_CONTRACT_ID ?? '',
NEXT_PUBLIC_HORIZON_URL: process.env.NEXT_PUBLIC_HORIZON_URL ?? '',
},
async headers() {
return [
{
source: '/sw.js',
headers: [
{ key: 'Cache-Control', value: 'public, max-age=0, must-revalidate' },
{ key: 'Content-Type', value: 'application/javascript' },
],
},
{
source: '/:path*',
headers: [
{ key: 'Content-Security-Policy', value: CSP },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
// Clickjacking protection — meaningful here since this is a
// payments UI (stream creation/withdrawal), not just marketing pages.
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
],
},
];
},
};
export default nextConfig;