generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
86 lines (75 loc) · 2.13 KB
/
next.config.js
File metadata and controls
86 lines (75 loc) · 2.13 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
/** @type {import('next').NextConfig} */
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const amplifyConfig = require('./amplify_outputs.json');
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? '/templates';
const domain = process.env.NOTIFY_DOMAIN_NAME ?? 'localhost:3000';
const nextConfig = (phase) => {
const isDevServer = phase === PHASE_DEVELOPMENT_SERVER;
const includeAuthPages =
process.env.INCLUDE_AUTH_PAGES === 'true' || isDevServer;
return {
basePath,
env: {
basePath,
API_BASE_URL: amplifyConfig?.meta?.api_base_url,
},
sassOptions: {
quietDeps: true,
},
experimental: {
serverActions: {
allowedOrigins: ['**.nhsnotify.national.nhs.uk', 'notify.nhs.uk'],
bodySizeLimit: '6mb',
},
},
async redirects() {
return [
{
source: '/',
destination: basePath,
basePath: false,
permanent: false,
},
{
source: `${basePath}/auth/inactive`,
destination: '/auth/inactive',
permanent: false,
basePath: false,
},
{
source: `${basePath}/auth/signout`,
destination: '/auth/signout',
basePath: false,
permanent: false,
},
];
},
async rewrites() {
if (includeAuthPages) {
return [
{
source: '/auth/inactive',
destination: `http://${domain}${basePath}/auth/idle`,
basePath: false,
},
{
source: '/auth/signout',
destination: `http://${domain}${basePath}/auth/signout`,
basePath: false,
},
{
source: '/auth',
destination: `http://${domain}${basePath}/auth`,
basePath: false,
},
];
}
return [];
},
// pages with e.g. .dev.tsx extension are only included when running locally
pageExtensions: ['ts', 'tsx', 'js', 'jsx'].flatMap((extension) => {
return includeAuthPages ? [`dev.${extension}`, extension] : [extension];
}),
};
};
module.exports = nextConfig;