Answer the question
In order to leave comments, you need to log in
Application deployment nuances?
Hello! There was a need to deploy my service (I use the google cloud platform). And since I had never encountered this before, a couple of questions arose.
const {Pool} = require('pg');
const pool = new Pool({
user: "macbookpro",
password: "root",
host: "localhost",
port: 5432,
database: "umuse"
});
module.exports = pool;
import io from 'socket.io-client';
const socket = io('http://localhost:5000');
export default socket;
Answer the question
In order to leave comments, you need to log in
1. Make sure that the config is loaded from .env
the environment variables using the dotenv module - this is the most classic practice. The database will need to be deployed either on the same machine where you are deploying (you can do it with docker-compose) or on a neighboring machine that you can access from the first one. Make sure that the data between the database and the application does not race over the Internet, as this a) reduces security to zero if there is no ssl and b) greatly reduces performance.
2. It's best to either not specify anything here, or specify 0.0.0.0, then all interfaces will listen and you won't have to bother with ip addresses. Or there is a more advanced option when you leave localhost, but nginx with proxy_pass is placed in front of the node application. In the second case, it will also be possible to attach an ssl certificate using letsencrypt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question