没有为 FingerprintJS 定义 ReferenceError 导航器

ReferenceError navigator is not defined for FingerprintJS

我正在尝试借助 fingerprintjs2(Javascript 中的一个 npm 模块获取浏览器指纹。但它给了我以下错误:-

ReferenceError: navigator is not defined

日志:

代码:

const Fingerprint = require('fingerprintjs2');
const express = require('express');
const cors = require('cors');
const mysql = require('mysql');
const app = express();

const fpInstance = new Fingerprint();
fpInstance.get((result,err)=>{
    if(err){
        console.log('Error obtained',err)
    }
    else{
        console.log(result)
    } 
})

我发现 fingerprintjs2 是一个 Javascript 库,在 Node.js 中不能正常工作。幸运的是,服务器端版本已经发布,即 Fingerprint express middleware,用于所谓的 被动指纹识别 .

安装: npm install express-fingerprint

用法:

var Fingerprint = require('express-fingerprint')

app.use(Fingerprint({
    parameters:[
        // Defaults
        Fingerprint.useragent,
        Fingerprint.acceptHeaders,
        Fingerprint.geoip,

        // Additional parameters
        function(next) {
            // ...do something...
            next(null,{
            'param1':'value1'
            })
        },
        function(next) {
            // ...do something...
            next(null,{
            'param2':'value2'
            })
        },
    ]
}))

app.get('*',function(req,res,next) {
    // Fingerprint object
    console.log(req.fingerprint)
})