-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathnext.config.ts
More file actions
110 lines (104 loc) · 2.75 KB
/
next.config.ts
File metadata and controls
110 lines (104 loc) · 2.75 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
import { NextConfig } from "next";
import { env } from "@/env";
import createBundleAnalyzer from "@next/bundle-analyzer";
import createMDX from "@next/mdx";
import createNextIntlPlugin from "next-intl/plugin";
const config: NextConfig = {
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
images: {
remotePatterns: [
{
protocol: "https",
hostname: "assets.usul.ai",
pathname: "/**",
},
],
},
turbopack: {
},
headers: async () => {
const headers: Awaited<ReturnType<NonNullable<NextConfig["headers"]>>> = [
{
// Large vendor assets under public/static (e.g. PDF viewer); filenames are not
// content-hashed, so use SWR instead of immutable.
source: "/static/:path*",
headers: [
{
key: "Cache-Control",
value:
"public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400",
},
],
},
{
// Cache sitemap
source: "/sitemap.xml",
headers: [
{
key: "Cache-Control",
value:
"public, max-age=60, s-maxage=600, stale-while-revalidate=14400, stale-if-error=14400",
},
],
},
];
// disable indexing on non-production environments
if (env.VERCEL_ENV !== "production") {
headers.push({
source: "/:path*",
headers: [
{
key: "X-Robots-Tag",
value: "noindex, nofollow",
},
],
});
}
return headers;
},
redirects: async () => {
return [
{
// Redirects from /regions/:region to /region/:region
source: "/regions/:region",
destination: "/region/:region",
permanent: true,
},
{
// Redirects from /authors/:authorSlug to /author/:authorSlug
source: "/authors/:authorSlug",
destination: "/author/:authorSlug",
permanent: true,
},
{
// Redirects from /centuries/:century to /century/:century
source: "/centuries/:century",
destination: "/century/:century",
permanent: true,
},
{
// Redirects from /genres/:genreSlug to /genre/:genreSlug
source: "/genres/:genreSlug",
destination: "/genre/:genreSlug",
permanent: true,
},
];
},
};
const plugins = [
createBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
}),
createMDX({
options: {
remarkPlugins: [],
rehypePlugins: [],
},
}),
createNextIntlPlugin("./src/i18n/request.ts"),
];
export default plugins.reduce((acc, plugin) => plugin(acc), config);