-
Notifications
You must be signed in to change notification settings - Fork 74
/
next.config.mjs
91 lines (88 loc) · 2.11 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
// @ts-check
const cache_control = (/** @type {number} */ time) => [
{
key: "Cache-Control",
value: `max-age=${time}, s-maxage=${time}, stale-while-revalidate=${time}`,
},
{
key: "CDN-Cache-Control",
value: `max-age=${time}`,
},
{
key: "Cloudflare-CDN-Cache-Control",
value: `max-age=${time}`,
},
{
key: "Vercel-CDN-Cache-Control",
value: `max-age=${time}`,
},
];
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
async headers() {
return [
{
source: "/(.*)",
headers: cache_control(86400),
},
{
source: "/api/users/(.*)",
headers: cache_control(86400),
},
{
source: "/pgc/view/v2/app/season(.*)",
headers: cache_control(86400),
},
{
source: "/pgc/view/web/season(.*)",
headers: cache_control(86400),
},
{
source: "/x/v2/search/type(.*)",
headers: cache_control(43200),
},
{
source: "/x/web-interface/search/type(.*)",
headers: cache_control(43200),
},
];
},
async rewrites() {
return [
{
source: "/pgc/:path(.*)",
destination: "/api/legacy/pgc/:path*",
},
{
source: "/x/:path(.*)",
destination: "/api/legacy/x/:path*",
},
{
source: "/intl/:path(.*)",
destination: "/api/legacy/intl/:path*",
},
{
source: "/api/server_info(.*)",
destination: "/api/legacy/server_info",
},
{
source: "/bilibili.app.playurl.v1.PlayURL/:path(.*)",
destination:
"https://grpc.biliapi.net/api/grpc/bilibili.app.playurl.v1.PlayURL/:path*",
},
{
source: "/bilibili.pgc.gateway.player.v1.PlayURL/:path(.*)",
destination:
"https://app.bilibili.com/api/grpc/bilibili.pgc.gateway.player.v1.PlayURL/:path*",
},
{
source: "/bilibili.community.service.dm.v1.DM/:path(.*)",
destination:
"https://app.bilibili.com/api/grpc/bilibili.community.service.dm.v1.DM/:path*",
},
];
},
};
export default nextConfig;