How to set up local subdomains for Node.js app

前端 未结 4 405
北海茫月
北海茫月 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:15

    on Ubuntu

    For creating subdomains for localhost you just need to follow 2 simple steps.

    Open your terminal by pressing CTRL + ALT + T then run the following commands:

    sudo vi hosts
    sudo -i gedit /etc/hosts # to edit /etc/hosts file
    

    Once you run 2nd command /etc/hosts file will open and now this is the place where you need to define subdomains.

    Example: localhost is:

    127.0.0.1       //our localhost
    
    define new subdomain:
    127.0.0.1       example.localhost   # first
    

    and another..

    127.0.0.1       demo.localhost      #second
    

    that's it. Hope this was helpful.

提交回复
热议问题