use of dotenv to get url and port.

This commit is contained in:
unurled 2022-02-23 11:31:46 +01:00
parent 5dede3767b
commit 21e059fd33
5 changed files with 8 additions and 4 deletions

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
URL="http://localhost"
SERVER_PORT="3030"

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
node_modules/
package-lock.json
.env

View file

@ -9,7 +9,7 @@
"author": "unurled",
"license": "ISC",
"dependencies": {
"dotenv": "^14.3.0",
"dotenv": "^14.3.2",
"express": "^4.17.2",
"express-session": "^1.17.2",
"jsonwebtoken": "^8.5.1",

View file

@ -1,3 +1,4 @@
require('dotenv').config()
var express = require('express');
var session = require('express-session');
var bodyParser = require('body-parser');
@ -46,4 +47,4 @@ app.get('/edit', function(request, res) {
}
});
app.listen(3000, console.log("http://localhost:3000"))
app.listen(process.env.SERVER_PORT, console.log(process.env.URL + '/' + process.env.SERVER_PORT))

View file

@ -10,6 +10,6 @@ function buildHeaders(authorization = null) {
return headers;
}
const response = await fetchService.performGetHttpRequest('http://localhost:3000/text', buildHeaders());
const response = await fetchService.performGetHttpRequest(window.location.href + 'text', buildHeaders());
document.getElementById("text").innerHTML = response.text;