next.config.ts (2435B)
1 import type { NextConfig } from "next"; 2 import withPWAInit from "@ducanh2912/next-pwa"; 3 4 const cspHeader = ` 5 default-src 'self'; 6 script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.onesignal.com https://onesignal.com https://static.cloudflareinsights.com https://www.googletagmanager.com; 7 style-src 'self' 'unsafe-inline'; 8 img-src 'self' blob: data: https://lh3.googleusercontent.com https://cdn.discordapp.com https://*.onesignal.com https://www.google-analytics.com https://www.googletagmanager.com; 9 font-src 'self'; 10 connect-src 'self' https://*.supabase.co wss://*.supabase.co https://*.onesignal.com https://onesignal.com https://cloudflareinsights.com https://static.cloudflareinsights.com https://www.google-analytics.com https://www.googletagmanager.com https://cdn.discordapp.com; 11 object-src 'none'; 12 base-uri 'self'; 13 upgrade-insecure-requests; 14 frame-ancestors 'none'; 15 form-action 'self'; 16 `.replace(/\s{2,}/g, " ").trim(); 17 18 const nextConfig: NextConfig = { 19 poweredByHeader: false, 20 21 images: { 22 remotePatterns: [ 23 { 24 protocol: 'https', 25 hostname: 'lh3.googleusercontent.com', 26 }, 27 ], 28 unoptimized: true, 29 }, 30 31 async headers() { 32 return [ 33 { 34 source: '/api/:path*', 35 headers: [ 36 { 37 key: 'Access-Control-Allow-Origin', 38 value: 'https://rabbit1.cc', 39 }, 40 { 41 key: 'Access-Control-Allow-Methods', 42 value: 'GET,POST,OPTIONS,DELETE,PATCH', 43 }, 44 { 45 key: 'Access-Control-Allow-Headers', 46 value: 'X-CSRF-Token, X-Requested-With, Accept, Content-Type, Authorization', 47 }, 48 ], 49 }, 50 { 51 source: '/:path*', 52 headers: [ 53 { key: 'Content-Security-Policy', value: cspHeader }, 54 { key: 'X-Frame-Options', value: 'DENY' }, 55 { key: 'X-Content-Type-Options', value: 'nosniff' }, 56 { key: 'Referrer-Policy', value: 'origin-when-cross-origin' }, 57 ], 58 }, 59 ]; 60 }, 61 62 turbopack: {}, 63 }; 64 65 const withPWA = withPWAInit({ 66 dest: "public", 67 register: true, 68 disable: process.env.NODE_ENV === "development", 69 publicExcludes: ["!OneSignalSDKWorker.js"], 70 workboxOptions: { 71 skipWaiting: true, 72 clientsClaim: true, 73 }, 74 }); 75 76 export default withPWA(nextConfig); 77 import('@opennextjs/cloudflare').then(m => m.initOpenNextCloudflareForDev());