Closed gbowne1 closed 1 year ago
In .env of server folder i going to add a variable for set a port for the backend app and you van put any port
It should not be any specific port. I forget how CRA does it, but it should see that 3000 is in use then ask you if you want to choose the next available port, in this case 3001 and then you just push y in the terminal/console to send the server to 3001 and it opens in 3001.
could write a server util to do this.
If I am working in many projects I have to start RadioLogger first then the other react, etc. projects that take 3xxx ports next.
I don't know if we are doing process.ENV.production and development. "production" would not have this functionality as it would only run on one port. "dev" could run on any port in the 3000-3999 range (as node &&& express lives in this range.)
Would it be useful if each one of us puts the port they want in the .env? that way the port I set doesn't need to be the same one you use. Another alternative is to use docker and set a port that is idle and maps to 3000
yes, that could be useful, just set a port. I typically have something already running on 3000 besides RadioLogger. I think we worked on this issue, but its not totally working in an ideal manner. I am also thinking of those other users and people that have something else running on 3000 already. I've had to go in and change the port locally at times.
Side note, I want to make a Docker container and a .devcontainer (a VSCode thing) for this project eventually. There is an issue for a .devcontainer.
I was thinking we could change line 61 - 64 in the server.js to
const server = app.listen(process.env.PORT || 3000, () => {
logger.info(`Server is listening on port: ${server.address().port}`);
});
PORT || being the decider. This would make this process easier. || would make the script take either the PORT variable or the 3000..
I made a change, to Night i push
ok. oh and I discovered that there are also some npm modules available for doing the same thing but that would be a lot of work. I also discovered node has a https module built in too.
Closing as fixed with refactor PR.
The backend and server will not forward the port if 3000 is already in use by something else.
You might see something like this in the server from nodemon. It should ask you if you want to choose the next available port like the Create React App development server does.