refactor: 移除无效的 headers 配置,安全头已在 nginx 中配置
This commit is contained in:
+4
-90
@@ -1,109 +1,23 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
|
||||||
const cdnDomain = process.env.CDN_DOMAIN || '';
|
const cdnDomain = process.env.CDN_DOMAIN || '';
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
distDir: 'dist',
|
distDir: 'dist',
|
||||||
output: 'standalone',
|
output: 'export',
|
||||||
assetPrefix: isDev ? undefined : cdnDomain,
|
assetPrefix: cdnDomain || undefined,
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
unoptimized: true,
|
||||||
{
|
|
||||||
protocol: 'https',
|
|
||||||
hostname: '**',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
formats: ['image/avif', 'image/webp'],
|
|
||||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
||||||
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
|
||||||
dangerouslyAllowSVG: true,
|
|
||||||
contentDispositionType: 'attachment',
|
|
||||||
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
|
|
||||||
minimumCacheTTL: 60,
|
|
||||||
unoptimized: !isDev,
|
|
||||||
},
|
},
|
||||||
compress: true,
|
compress: true,
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
reactProductionProfiling: !isDev,
|
|
||||||
experimental: {
|
experimental: {
|
||||||
optimizePackageImports: ['lucide-react'],
|
optimizePackageImports: ['lucide-react'],
|
||||||
},
|
},
|
||||||
compiler: {
|
compiler: {
|
||||||
removeConsole: process.env.NODE_ENV === 'production',
|
removeConsole: process.env.NODE_ENV === 'production',
|
||||||
},
|
},
|
||||||
headers: async () => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
source: '/:path*',
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
key: 'X-DNS-Prefetch-Control',
|
|
||||||
value: 'on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Strict-Transport-Security',
|
|
||||||
value: 'max-age=63072000; includeSubDomains; preload'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'X-XSS-Protection',
|
|
||||||
value: '1; mode=block'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'X-Frame-Options',
|
|
||||||
value: 'SAMEORIGIN'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'X-Content-Type-Options',
|
|
||||||
value: 'nosniff'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Referrer-Policy',
|
|
||||||
value: 'origin-when-cross-origin'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Permissions-Policy',
|
|
||||||
value: 'camera=(), microphone=(), geolocation=()'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: '/:all*(svg|jpg|jpeg|png|gif|webp|avif)',
|
|
||||||
locale: false,
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: '/_next/static/:all*',
|
|
||||||
locale: false,
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: '/fonts/:all*',
|
|
||||||
locale: false,
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'public, max-age=31536000, immutable',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Access-Control-Allow-Origin',
|
|
||||||
value: '*',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user