【问题标题】:How to work with wilcard subdomains on localhost in a node js application如何在节点 js 应用程序中使用本地主机上的通配符子域
【发布时间】:2019-03-10 20:00:43
【问题描述】:

我有一个应用程序作为 something.localhost (*.localhost) 运行,具体取决于需要识别的子域名操作。

【问题讨论】:

    标签: node.js node-modules


    【解决方案1】:

    您可以使用req.headers.host 来识别主机。

    app.get('*', (req, res, next) => { 
        if(req.headers.host == 'something.localhost') {
            //your code here
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-18
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 2010-10-15
      • 1970-01-01
      相关资源
      最近更新 更多