This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
next.config.js
102 lines (91 loc) · 3.51 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
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
92
93
94
95
96
97
98
99
100
101
102
/**
* Copyright (c) 2022, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
/*
* https://nextjs.org/docs/api-reference/next.config.js/introduction
* 'next.config.js' is a regular Node.js module, not a JSON file.
* It gets used by the Next.js server and build phases, and it's
* not included in the browser build.
*/
// use "next-images" to add the ability to import images as objects
// we are using this so that when the application is accessed through a reverse
// proxy to add a base path the images are still loaded correctly
const withImages = require('next-images');
const sdkPackage = require('./node_modules/@oracle/content-management-sdk/package.json');
const BUILD_TAG = process.env.BUILD_TAG || 'none';
const SDK_VERSION = sdkPackage.version;
/*
* Gets the BASE_URL from the command used to start this app.
* If BASE_URL is specified but it does not start with a "/" then add it.
*/
function getBaseUrl() {
let baseUrl = '';
if (process.env.BASE_URL) {
if (process.env.BASE_URL.startsWith('/')) {
baseUrl = process.env.BASE_URL;
} else {
baseUrl = `/${process.env.BASE_URL}`;
}
}
return baseUrl;
}
module.exports = withImages({
// disable Next 11 static images (could not get it working with png files)
images: {
disableStaticImages: true,
},
// Redirect / to /page which will determine the first page
async redirects() {
return [
{
source: '/',
destination: '/page/',
permanent: true,
},
];
},
// This is needed when you are running you application with a reverse
// proxy, this has to be the same value as what you put in your reverse
// proxy so that the pages, components, and scripts are located.
assetPrefix: getBaseUrl(),
// This variable is used in this application in <Link>s. This is so when
// this application is deployed in a server which has a reverse proxy,
// the Links have the correct path to the resource. Without this set links
// will not work
// For example : if the reverse proxy is passing
// "http://myhost/samples/oce-nextjs-minimal-sample/" on to "http://myhost",
// the link to the "contact" page has to be "http://myhost/tutorialsoce-nextjs-minimal-sample/contact"
// so the reverse proxy will forward it on to "http://myhost/contact"
publicRuntimeConfig: {
basePath: getBaseUrl(),
},
// make server environment variables accessible in the app even in the client bundle
env: {
NEXT_PUBLIC_BUILD_TAG: BUILD_TAG,
NEXT_PUBLIC_SDK_VERSION: SDK_VERSION,
NEXT_PUBLIC_SERVER_URL: process.env.SERVER_URL,
NEXT_PUBLIC_API_VERSION: process.env.API_VERSION,
NEXT_PUBLIC_CHANNEL_TOKEN: process.env.CHANNEL_TOKEN,
NEXT_PUBLIC_AUTH: process.env.AUTH,
NEXT_PUBLIC_LOGO_FILE_NAME: process.env.LOGO_FILE_NAME,
NEXT_PUBLIC_FOOTER_LOGO_FILE_NAME: process.env.FOOTER_LOGO_FILE_NAME,
NEXT_PUBLIC_HOME_IMAGE_FILE_NAME: process.env.HOME_IMAGE_FILE_NAME,
NEXT_PUBLIC_CONTACTUS_IMAGE_FILE_NAME: process.env.CONTACTUS_IMAGE_FILE_NAME,
},
// Add webpack exclusions to to allow it to integrate https-proxy-agent in non server context
webpack: (config, { isServer }) => {
if (!isServer) {
// eslint-disable-next-line no-param-reassign
config.resolve.fallback = {
// assert, net, tls needed for 'https-proxy-agent' dependency
assert: false,
net: false,
tls: false,
http: false,
https: false,
};
}
return config;
},
});