我有一个运行为something.localhost(* .localhost)的应用程序,具体取决于需要识别的子域名操作。
您可以使用req.headers.host来识别主机。
req.headers.host
app.get('*', (req, res, next) => { if(req.headers.host == 'something.localhost') { //your code here } });