Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Custom domain support for users with Node and Express
I want to offer support for custom domains for my users. I created a file in /etc/nginx/sites-avilable/ with a server block that routes everything to an Express app (running with PM2). I want to use Express to get the domain they are requesting from, cross reference that domain name, and show the appropriate user’s page. However, something like
req.headers.host only gives me ‘localhost:3000’. How can I get the domain name of the request? Or is there a simpler way of doing this?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×