mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Move device type detection to client side
We don't need the server to tell us our user agent--we can get it ourselves through navigator.userAgent and parse it on the frontend. I've replaced device-detector-js with Bowser because device-detector-js is really slow, freezing for up to 500ms to parse a single user agent.
This commit is contained in:
@@ -27,7 +27,6 @@ const responseTime = require('response-time');
|
||||
// net related library imports
|
||||
const net = require('net');
|
||||
const dns = require('dns');
|
||||
const DeviceDetector = require('device-detector-js');
|
||||
const fetch = require('node-fetch').default;
|
||||
const ipaddr = require('ipaddr.js');
|
||||
const ipMatching = require('ip-matching');
|
||||
@@ -293,12 +292,6 @@ app.use(multer({ dest: UPLOADS_PATH, limits: { fieldSize: 10 * 1024 * 1024 } }).
|
||||
app.get('/', function (request, response) {
|
||||
response.sendFile(process.cwd() + '/public/index.html');
|
||||
});
|
||||
app.get('/deviceinfo', function (request, response) {
|
||||
const userAgent = request.header('user-agent');
|
||||
const deviceDetector = new DeviceDetector();
|
||||
const deviceInfo = deviceDetector.parse(userAgent || '');
|
||||
return response.send(deviceInfo);
|
||||
});
|
||||
app.get('/version', async function (_, response) {
|
||||
const data = await getVersion();
|
||||
response.send(data);
|
||||
|
Reference in New Issue
Block a user