generated from timlrx/tailwind-nextjs-starter-blog
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
66 lines (62 loc) · 2.4 KB
/
next.config.js
File metadata and controls
66 lines (62 loc) · 2.4 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
/* eslint-disable @typescript-eslint/no-require-imports */
const { withContentlayer } = require('next-contentlayer2')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const ContentSecurityPolicy = `
default-src *;
script-src * 'unsafe-inline' 'unsafe-eval' blob: data:;
style-src * 'unsafe-inline' blob: data:;
img-src * blob: data:;
media-src * blob:;
connect-src *;
font-src * data:;
frame-src *;
`
const securityHeaders = [
{
key: 'Content-Security-Policy',
value: ContentSecurityPolicy.replace(/\n/g, ''),
},
{ key: 'Referrer-Policy', value: 'no-referrer' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'X-DNS-Prefetch-Control', value: 'on' },
{ key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
]
/* ──────────────────────────────────────────────────────────── */
/* ② 其余配置保持不变 */
/* ──────────────────────────────────────────────────────────── */
const output = process.env.EXPORT ? 'export' : undefined
const basePath = process.env.BASE_PATH || undefined
const unoptimized = !!process.env.UNOPTIMIZED
/** @type {import('next/dist/next-server/server/config').NextConfig} */
module.exports = () => {
const plugins = [withContentlayer, withBundleAnalyzer]
return plugins.reduce((acc, next) => next(acc), {
output,
basePath,
reactStrictMode: true,
trailingSlash: false,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
eslint: { dirs: ['app', 'components', 'layouts', 'scripts'] },
images: {
remotePatterns: [
{ protocol: 'https', hostname: '*' },
// { protocol: 'https', hostname: 'forum.cocos.org' },
],
unoptimized,
},
async headers() {
return [{ source: '/(.*)', headers: securityHeaders }]
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
})
return config
},
})
}