I'm a bit new to servers like Nginx/Apache/other servers.
I'm working on a web project, and I want the client to be able to interact with the server. However, the client is on port 3000 and my server is on port 8000. I figured out that I needed a way to serve static files, while also having a reverse proxy. I heard that is what Nginx is for.
In development, I can do something like this with vite.
export default defineConfig({
server:{
proxy:{
'/api': 'http://localhost:8000'
}
}
})
The thing is, vite is for development and not for production. I could probably use serve
, but that doesn't support reverse proxies, I believe. I could also use Nginx, but the Nginx configuration files are not relative to project, but they are absolute files. I don't like that since I want to add the Nginx config files to my GitHub repo, and it could conflict with other future projects. If there is a way to commit Nginx config files, I would appreciate it if you let me know.
If there are alternatives to Nginx/Apache that I can commit to my project, let me know.
Sorry, I just learned of
http-server
from node.js, and it has what I need.