forked from plone/plone-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
49 lines (43 loc) · 1.39 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
49
const path = require('path');
/** @type {import('next').NextConfig} */
const nextConfig = {
// sassOptions: {
// includePaths: [path.join(__dirname, 'src/lib/components/src/styles')],
// },
// webpack(config) {
// config.resolve.alias = {
// ...config.resolve.alias,
// '../fonts': path.resolve(__dirname, 'src/lib/components/src/fonts'),
// };
// return config;
// },
// Rewrite to the backend to avoid CORS
async rewrites() {
let apiServerURL, vhmRewriteRule;
if (process.env.API_SERVER_URL) {
apiServerURL = process.env.API_SERVER_URL;
vhmRewriteRule = `/VirtualHostBase/https/${process.env.NEXT_PUBLIC_VERCEL_URL}%3A443/Plone/%2B%2Bapi%2B%2B/VirtualHostRoot`;
} else if (
process.env.API_SERVER_URL &&
!process.env.NEXT_PUBLIC_VERCEL_URL
) {
throw new Error(
'API_SERVER_URL set and NEXT_PUBLIC_VERCEL_URL not present.',
);
} else {
apiServerURL = 'http://localhost:8080';
vhmRewriteRule =
'/VirtualHostBase/http/localhost%3A3000/Plone/%2B%2Bapi%2B%2B/VirtualHostRoot';
}
return [
{
source: '/\\+\\+api\\+\\+/:slug*',
destination:
// 'https://static.197.123.88.23.clients.your-server.de/api/:slug*',
// `${apiServerURL}/:slug*`,
`${apiServerURL}${vhmRewriteRule}/:slug*`,
},
];
},
};
module.exports = nextConfig;