-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnext.config.js
More file actions
93 lines (88 loc) · 2.54 KB
/
next.config.js
File metadata and controls
93 lines (88 loc) · 2.54 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
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
/** @type {import('next').NextConfig} */
// For preview deploys, derive AUTH0_BASE_URL from the stable branch URL
// so Auth0 callbacks work without per-branch env var configuration
const auth0BaseUrl =
process.env.AUTH0_BASE_URL ||
(process.env.VERCEL_BRANCH_URL
? `https://${process.env.VERCEL_BRANCH_URL}`
: undefined);
const nextConfig = {
// Inline AUTH0_BASE_URL at build time so it's available in all runtimes
// (edge middleware + serverless functions)
...(auth0BaseUrl ? { env: { AUTH0_BASE_URL: auth0BaseUrl } } : {}),
async redirects() {
return [
{
source: '/profile',
destination: '/settings',
permanent: true,
},
];
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{
key: 'Access-Control-Allow-Methods',
value: 'GET,POST,PUT,DELETE,OPTIONS,PATCH',
},
{
key: 'Access-Control-Allow-Headers',
value:
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version',
},
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
],
},
];
},
//prevent react from loading components twice
reactStrictMode: false,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
},
{
protocol: 'https',
hostname: '*.public.blob.vercel-storage.com',
},
{
protocol: 'https',
hostname: '*.googleusercontent.com',
},
],
},
experimental: {
serverComponentsExternalPackages: ['braintrust'],
// This is supposed to prevent route handler caching
serverActions: {
allowedOrigins: ['localhost:3000'],
bodySizeLimit: '10mb',
},
},
webpack: (config, { isServer }) => {
// Prevent bundling of native node modules
config.resolve.fallback = {
...config.resolve.fallback,
'onnxruntime-node': false,
};
config.ignoreWarnings = [
{ module: /node_modules\/onnxruntime-node/ },
{ module: /node_modules\/@huggingface\/transformers/ },
{ message: /Critical dependency: Accessing import\.meta directly is unsupported/ }
];
// Add a rule to handle .node files
config.module.rules.push({
test: /\.node$/,
use: 'node-loader',
type: 'javascript/auto',
});
return config;
},
};
module.exports = nextConfig;