sequenceTubeMap icon indicating copy to clipboard operation
sequenceTubeMap copied to clipboard

port should be 3001 in the src/server.mjs

Open lixiang117423 opened this issue 8 months ago • 4 comments

The line 56 should be:

const SERVER_PORT = process.env.SERVER_PORT || config.serverPort || 3001;

lixiang117423 avatar Mar 26 '25 09:03 lixiang117423

I don't think that's right?

The SERVER_PORT used in the server.mjs API server needs to be a different port than the one used by the React dev server, in the development setup. Right now we have the React dev server running on port 3001, and it uses a proxy setup to forward along API requests from the browser to the API on port 3000. When you run npm run start, the browser opens to port 3001 and talks to the React dev server for hot reloading, and the API requests go through the React dev server on port 3001 and are proxied by it to server.mjs on port 3000.

The proxy setup code is here:

https://github.com/vgteam/sequenceTubeMap/blob/1bb2a57a47ada9a46d2a5fe768a5747d9c6a302f/src/setupProxy.js#L26

I think that code might need to pull in config.serverPort, since right now it looks like if you set config.serverPort and run the dev setup it will change where the API server listens but not where the proxy points.

Why do you think the API server should default to port 3001?

adamnovak avatar Mar 26 '25 15:03 adamnovak

I don't think that's right?

The SERVER_PORT used in the server.mjs API server needs to be a different port than the one used by the React dev server, in the development setup. Right now we have the React dev server running on port 3001, and it uses a proxy setup to forward along API requests from the browser to the API on port 3000. When you run npm run start, the browser opens to port 3001 and talks to the React dev server for hot reloading, and the API requests go through the React dev server on port 3001 and are proxied by it to server.mjs on port 3000.

The proxy setup code is here:

sequenceTubeMap/src/setupProxy.js

Line 26 in 1bb2a57

(process.env.SERVER_PORT || "3000"); I think that code might need to pull in config.serverPort, since right now it looks like if you set config.serverPort and run the dev setup it will change where the API server listens but not where the proxy points.

Why do you think the API server should default to port 3001?

For me , if the port is 3000, the error is:

Image

However, if the port is 3001, the software works properly. I have tested this on both Ubuntu 22.04 and WSL, and I had to modify the port to 3001 to get it running successfully. Perhaps this is just a bug specific to my setup.

Image

Image

lixiang117423 avatar Apr 01 '25 09:04 lixiang117423

OK, I forgot that in the documentation we tell people to do npm run build and npm run serve, to use the API server itself as the web server instead of the React dev server. When I do that, the API server starts up on port 3000, but the documentation says you need to go to port 3001 to use it, which is wrong.

We could either change the docs to show you going to port 3000 (to match the start commands in the docs, but which means the dev version and the "local install" version will run on different ports with different URLs), or we could try and make npm run serve put the API server on port 3001 and npm run start keep it on port 3000 with the React dev server on 3001.

As for why you are getting an error @lixiang117423, I think that's because you already have something else running on port 3000 already, so the server can't use it. You can run SERVER_PORT=3123 npm run serve to put the server on port 3123, or any free port number you want, if the default port is not available in your setup.

adamnovak avatar Apr 10 '25 14:04 adamnovak

I can't actually move the default npm run serve port to 3001 without adding new stuff to the demo deployment to move it back there or deal with the change. But I have a PR now to update the docs to say what to do about EADDRINUSE and to have the right port in the URLs they give you.

adamnovak avatar Apr 10 '25 15:04 adamnovak