-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext-handlers.js
65 lines (64 loc) · 1.7 KB
/
next-handlers.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const handlers = {
/**
* @description
* Headers allow you to set custom HTTP headers for an incoming request path (Next.js 9.5 and up).
*
* @see
* [https://nextjs.org/docs/api-reference/next.config.js/headers](https://nextjs.org/docs/api-reference/next.config.js/headers)
*/
async headers() {
return [
{
source: '/api/unfurl',
headers: [
{
key: 'Cache-Control',
value: 's-maxage=10, stale-while-revalidate',
},
],
},
];
},
/**
* @description
* Redirects allow you to redirect an incoming request path to a different destination path (Next.js 9.5 and up).
*
* @see
* [https://nextjs.org/docs/api-reference/next.config.js/redirects](https://nextjs.org/docs/api-reference/next.config.js/redirects)
*/
async redirects() {
return [
{
source: '/_preview',
destination: '/_preview/SanityCheck',
permanent: true,
},
{
source: '/github',
destination: process.env.NEXT_PUBLIC_GITHUB_REPO,
permanent: false,
},
{
source: '/analytic',
destination: process.env.NEXT_PUBLIC_SHARE_ANALYTIC || '/404',
permanent: false,
},
];
},
/**
* @description
* Rewrites allow you to map an incoming request path to a different destination path (Next.js 9.5 and up).
*
* @see
* [https://nextjs.org/docs/api-reference/next.config.js/rewrites](https://nextjs.org/docs/api-reference/next.config.js/rewrites)
*/
async rewrites() {
return [
{
source: '/service-worker.js',
destination: '/_next/static/service-worker.js',
},
];
},
};
module.exports = handlers;