-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathnext.config.ts
111 lines (101 loc) · 2.98 KB
/
next.config.ts
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { type NextConfig } from 'next';
/* eslint-disable @typescript-eslint/no-var-requires */
const { withAxiom } = require('next-axiom');
const withPWA = require('next-pwa')({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
register: true,
skipWaiting: true,
});
const baseCsp = `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://us-assets.i.posthog.com;
style-src 'self' 'unsafe-inline' https://unpkg.com https://fonts.googleapis.com;
img-src 'self' blob: data: https://res.cloudinary.com https://*.googleusercontent.com https://s2.coinmarketcap.com https://assets.coingecko.com https://avatars.githubusercontent.com;
connect-src 'self' blob: https://auth.privy.io https://*.rpc.privy.systems https://api.mainnet-beta.solana.com https://api.devnet.solana.com https://api.testnet.solana.com https://us.i.posthog.com https://app.posthog.com https://*.helius-rpc.com wss://mainnet.helius-rpc.com https://ipapi.co wss://earn-vibe-production.up.railway.app;
font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com;
child-src 'self' https://auth.privy.io;
frame-src 'self' https://auth.privy.io;
frame-ancestors 'self';
${process.env.NODE_ENV === 'production' ? 'upgrade-insecure-requests;' : ''}
`;
const csp = baseCsp.replace(/\s{2,}/g, ' ').trim();
const nextConfig: NextConfig = {
eslint: {
dirs: ['.'],
},
poweredByHeader: false,
trailingSlash: true,
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
pathname: '**',
},
{
protocol: 'https',
hostname: '*.googleusercontent.com',
pathname: '**',
},
],
formats: ['image/avif', 'image/webp'],
},
experimental: {
optimizePackageImports: [
'@radix-ui/react-icons',
'flag-icons',
'@tiptap/core',
'react-select',
'posthog-js',
'posthog-js/react',
'lowlight',
'zod',
'@privy-io/react-auth',
'@privy-io/server-auth',
],
},
async headers() {
const headers = [];
headers.push({
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'Content-Security-Policy',
value: csp,
},
],
});
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
headers.push({
source: '/:path*',
headers: [
{
key: 'X-Robots-Tag',
value: 'noindex',
},
],
});
}
return headers;
},
async rewrites() {
return [
{
source: '/ingest/static/:path*',
destination: 'https://us-assets.i.posthog.com/static/:path*',
},
{
source: '/ingest/:path*',
destination: 'https://us.i.posthog.com/:path*',
},
];
},
};
const combinedConfig = withAxiom(withPWA(nextConfig));
module.exports = combinedConfig;