This repository was archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnext.config.mjs
More file actions
49 lines (43 loc) · 1.36 KB
/
next.config.mjs
File metadata and controls
49 lines (43 loc) · 1.36 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
import withMarkdoc from '@markdoc/next.js'
import nextPWA from 'next-pwa'
import runtimeCaching from 'next-pwa/cache.js'
import withSearch from './src/markdoc/search.mjs'
const getCorsHeaders = () => {
const headers = {}
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Credentials'] = 'true'
headers['Access-Control-Allow-Methods'] = 'GET,OPTIONS,PATCH,DELETE,POST,PUT'
headers['Access-Control-Allow-Headers'] = 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization'
return Object.entries(headers).map(([key, value]) => ({ key, value }))
}
const withPWA = nextPWA({
dest: 'public',
runtimeCaching,
disable: process.env.NODE_ENV === 'development',
})
/** @type {import('next').NextConfig} */
const nextConfig = {
trailingSlash: false,
skipTrailingSlashRedirect: true,
reactStrictMode: true,
images: {
unoptimized: true,
},
pageExtensions: ['js', 'jsx', 'md'],
generateBuildId: async () => {
if (process.env.BUILD_ID) {
return process.env.BUILD_ID
} else {
return `${new Date().getTime()}`
}
},
headers: async () => {
return [
{
source: '/api/(.*)',
headers: getCorsHeaders(),
},
]
},
}
export default withSearch(withMarkdoc({ schemaPath: './src/markdoc' })(withPWA(nextConfig)))