如何在节点js应用程序中的localhost上使用通配符子域

问题描述 投票:-1回答:1

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

node.js node-modules
1个回答
0
投票

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

app.get('*', (req, res, next) => { 
    if(req.headers.host == 'something.localhost') {
        //your code here
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.