如果您正在使用express,您可以尝试以下方法:app.get('/', (req, res, next) => { if (req.protocol === 'https') console.log(req.connection.getProtocol()); else console.log('Not SSL'); });