/
next.config.js
48 lines (44 loc) · 1.28 KB
/
next.config.js
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
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
function getBaseURL() {
switch (process.env.VERCEL_ENV) {
case "production":
return "https://oui.is";
case "preview":
return `https://${process.env.VERCEL_URL}`;
default:
return "http://localhost:3000";
}
}
function getHeaders() {
if (process.env.VERCEL_ENV === "production") {
const headers = async () => [
{
source: "/",
headers: [
{
key: "cache-control",
value: "max-age=9, s-maxage=1, stale-while-revalidate=59",
},
{ key: "cdn-cache-control", value: "s-maxage=60" },
{ key: "vercel-cdn-cache-control", value: "s-maxage=3600" },
],
},
];
return headers;
}
return undefined;
}
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverActions: true,
optimizePackageImports: ["@ark-ui/react"],
},
env: {
NEXT_PUBLIC_BASE_URL: getBaseURL(),
},
headers: getHeaders(),
};
module.exports = withBundleAnalyzer(nextConfig);