forked from LibreChat-AI/librechat.ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
134 lines (125 loc) · 3.29 KB
/
next.config.mjs
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* eslint-disable no-undef */
import remarkGfm from 'remark-gfm'
import nextra from 'nextra'
import NextBundleAnalyzer from '@next/bundle-analyzer'
const withBundleAnalyzer = NextBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
/**
* CSP headers
* img-src https to allow loading images from SSO providers
*/
const cspHeader = `
default-src 'self' https: wss:;
script-src 'self' 'unsafe-eval' 'unsafe-inline' https:;
style-src 'self' 'unsafe-inline' https:;
img-src 'self' https: blob: data:;
media-src 'self' https: blob: data:;
font-src 'self' https:;
frame-src 'self' https:;
worker-src 'self' blob:;
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
upgrade-insecure-requests;
block-all-mixed-content;
`
const nonPermanentRedirects = [
// Up to date Redirects:
['/discord', 'https://discord.librechat.ai'],
['/demo', 'https://demo.librechat.cfd'],
['/issue', 'https://github.com/danny-avila/LibreChat/issues/new/choose'],
['/new-issue', 'https://github.com/danny-avila/LibreChat/issues/new/choose'],
['/issues', 'https://github.com/danny-avila/LibreChat/issues'],
['/gh-support', 'https://github.com/danny-avila/LibreChat/discussions/categories/support'],
['/gh-discussions', 'https://github.com/danny-avila/LibreChat/discussions'],
['/roadmap', '/docs/roadmap'],
// Redirect to overview pages
...[].map((path) => [path, path + '/overview']),
]
const permanentRedirects = []
// nextra config
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
mdxOptions: {
remarkPlugins: [remarkGfm],
},
latex: {
renderer: 'mathjax'
},
defaultShowCopyCode: true,
})
// next config
const nextraConfig = withNextra({
experimental: {
esmExternals: 'loose', // <-- add this
serverComponentsExternalPackages: ['mongoose'],
scrollRestoration: true,
},
transpilePackages: ['react-tweet', 'react-syntax-highlighter', 'geist'],
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'static.librechat.ai',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'github.com',
port: '',
pathname: '/**',
},
],
},
headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'x-frame-options',
value: 'SAMEORIGIN',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'Permissions-Policy',
value: 'autoplay=*, fullscreen=*, microphone=*',
},
],
},
{
source: '/:path((?!api).*)*',
headers: [
{
key: 'Content-Security-Policy',
value: cspHeader.replaceAll('\n', ''),
},
],
},
]
},
redirects: async () => [
...nonPermanentRedirects.map(([source, destination]) => ({
source,
destination,
permanent: false,
})),
...permanentRedirects.map(([source, destination]) => ({
source,
destination,
permanent: false,
})),
],
})
export default withBundleAnalyzer(nextraConfig)