-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
54 lines (48 loc) · 2 KB
/
next.config.js
File metadata and controls
54 lines (48 loc) · 2 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
const {
PHASE_DEVELOPMENT_SERVER,
PHASE_PRODUCTION_BUILD,
} = require('next/constants');
console.log('!!!PHASES:', PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD);
// This uses phases as outlined here: https://nextjs.org/docs/#custom-configuration
module.exports = (phase) => {
// when started in development mode `next dev` or `npm run dev` regardless of the value of STAGING environmental variable
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
// when `next build` or `npm run build` is used
const isProd =
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1';
// when `next build` or `npm run build` is used
const isStaging =
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1';
//put ec2 instance link
const EC2AWS = 'http://ec2-3-66-89-198.eu-central-1.compute.amazonaws.com';
console.log(`isDev:${isDev} isProd:${isProd} isStaging:${isStaging}`);
console.log('DB', process.env.DB);
const env = {
RESTURL: (() => {
if (isDev) return 'http://localhost:3000';
if (isProd && process.env.DB !== 'AWS') {
return 'https://kr-web.klishevich.ru';
}
if (isProd && process.env.DB === 'AWS') {
return EC2AWS;
}
if (isStaging) return 'https://localhost:3000';
return 'RESTURL:not (isDev,isProd && !isStaging,isProd && isStaging)';
})(),
RESTURL_SESSIONS: (() => {
if (isDev) return 'http://localhost:3000/sessions';
if (isProd && process.env.DB !== 'AWS') {
return 'https://kr-web.klishevich.ru/sessions';
}
if (isProd && process.env.DB === 'AWS') {
return `${EC2AWS}/sessions`;
}
if (isStaging) return 'http://localhost:3000';
return 'RESTURL_SESSIONS:not (isDev,isProd && !isStaging,isProd && isStaging)';
})(),
};
// next.config.js object
return {
env,
};
};