forked from superhuit-agency/superstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
51 lines (46 loc) · 1.13 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
50
51
const {
getWpDomain,
getWpUrl,
getWpFormsSecret,
} = require('./src/utils/node-utils.js');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
console.log('images domains:', getWpDomain());
/** @type {import('next').NextConfig} */
const nextConfig = {
trailingSlash: true, // to match wp links format
images: {
remotePatterns: [
{
hostname: getWpDomain(),
},
],
},
rewrites() {
const wpUrl = getWpUrl();
const formSecrets = getWpFormsSecret();
return [
// Sitemap
{
source: '/sitemap:type*.xml',
destination: `/api/sitemap`,
},
// Poxy for WP uploads to not expose the WP domain
{
source: '/wp-content/uploads/:path*',
destination: `${wpUrl}/wp-content/uploads/:path*`,
},
// Proxy for WP forms
{
source: '/api/submit-form/',
destination: `${wpUrl}/?spckforms-action=submit-form&spckforms-secret=${formSecrets}`,
},
{
source: '/api/submit-form/upload/',
destination: `${wpUrl}/?spckforms-action=upload-file&spckforms-secret=${formSecrets}`,
},
];
},
};
module.exports = withBundleAnalyzer(nextConfig)