-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetBaseUrl.js
33 lines (28 loc) · 1.01 KB
/
setBaseUrl.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
//import { PORT } from './server.js';
import fs from 'fs';
import "./loadEnvironment.mjs";
const PORT = process.env.PORT || 5050;
console.log("Wrote baseUrl to frontend/src/config.js");
//use try catch
try {
if(process.env.PRODUCTION == "render") { //render.com server
fs.writeFileSync('./frontend/src/config.js', `export const baseUrl = 'musicsheets.onrender.com';`);
console.log("Wrote https://musicsheets.onrender.com to config.js");
}
else if(!!process.env.PARTITION) { //you might use NODE_ENV
fs.writeFileSync('./frontend/src/config.js', `export const baseUrl = 'musicsheets.in';`);
console.log("Wrote http://16.171.73.224 to config.js");
}
else {
fs.writeFileSync('./frontend/src/config.js', `export const baseUrl = 'localhost:${PORT}';`);
console.log(`Wrote localhost:${PORT} to config.js`);
}
} catch(err) {
console.error(err);
}
if (fs.existsSync('./frontend/src/config.js')) {
console.log('config.js file found');
}
else {
console.log("config.js file not found");
}