@azteam/express 1.2.256 → 1.2.258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/src/Server.js +6 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.256",
3
+ "version": "1.2.258",
4
4
  "main": "src/index.js",
5
5
  "engines": {
6
6
  "node": ">= 12.0.0",
@@ -29,6 +29,7 @@
29
29
  "method-override": "3.0.0",
30
30
  "morgan": "1.10.0",
31
31
  "socket.io": "4.4.1",
32
- "socket.io-redis": "6.1.0"
32
+ "socket.io-redis": "6.1.0",
33
+ "psl": "1.8.0"
33
34
  }
34
35
  }
package/src/Server.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  import fs from 'fs';
2
3
  import path from 'path';
3
4
  import http from 'http';
@@ -8,7 +9,7 @@ import bodyParser from 'body-parser';
8
9
  import cookieParser from 'cookie-parser';
9
10
  import morgan from 'morgan';
10
11
  import cors from 'cors';
11
- import _ from 'lodash';
12
+ import psl from 'psl';
12
13
  import 'express-async-errors';
13
14
  import {CORS, errorCatch, ErrorException, NOT_FOUND, UNKNOWN} from '@azteam/error';
14
15
 
@@ -262,6 +263,9 @@ class Server {
262
263
  app.use(function (req, res, next) {
263
264
  delete res.cache;
264
265
 
266
+ const parsed = psl.parse(req.get('Origin'));
267
+ req.rootOrigin = parsed.domain;
268
+
265
269
  req.trackDevice = {
266
270
  ip: req.headers['x-forwarded-for'] || req.headers['x-real-ip'] || req.ip,
267
271
  device: req.get('X-DEVICE') || req.get('User-Agent'),
@@ -315,6 +319,7 @@ class Server {
315
319
  return res.success({
316
320
  ...req.trackDevice,
317
321
  host: req.hostname,
322
+ origin: req.get('origin'),
318
323
  });
319
324
  });
320
325