How to set up local subdomains for Node.js app

前端 未结 4 404
北海茫月
北海茫月 2021-02-02 15:41

I am running an express app on node.js. The app uses the express-subdomain module to help handle routes for two different subdomains (sub1.example.com and sub2.example.com). I\'

4条回答
  •  长发绾君心
    2021-02-02 16:22

    There is an awesome website, which someone hosted for all of us.

    localtest.me

    All requests will be routed to 127.0.0.1, including subdomains. e.g something.localtest.me:3000 will resolve to 127.0.0.1:3000

    but, for example, in your Express app, if you do

     app.get('*', (req, res) => {
         console.log(req.subdomains); // [ something ]
     });
    
    

    you'll get your subdomain

提交回复
热议问题