@alizadefaig/pos-server 1.2.9 → 1.2.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alizadefaig/pos-server",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Server in express js with Proxy to Main server if need and will work with Electron JS",
5
5
  "homepage": "https://gitlab.com/faigalizade/pos-server#readme",
6
6
  "bugs": {
@@ -7,15 +7,18 @@ const moment = require("moment/moment");
7
7
 
8
8
  const proxy = createProxyMiddleware({
9
9
  target: 'http://localhost:3005',
10
+ preserveHeaderKeyCase: true,
10
11
  router: function (req) {
11
12
  // Подставляем URL из query или тела запроса
12
13
  const dynamicUrl = req.query.url || req.body?.url;
13
14
 
14
- if (!dynamicUrl) {
15
- return null; // не будет проксировать, Express продолжит обработку
16
- }
17
-
18
- return dynamicUrl;
15
+ const { protocol, host, pathname } = new URL(dynamicUrl);
16
+ // Сохраняем хост и протокол как target (без пути)
17
+ req._targetPath = pathname; // сохраняем путь, чтобы использовать в pathRewrite
18
+ return `${protocol}//${host}`;
19
+ },
20
+ pathRewrite: function (path, req) {
21
+ return req._targetPath || '/';
19
22
  },
20
23
  on: {
21
24
  proxyReq: (proxyReq, req, res, options) => {
package/server.js CHANGED
@@ -17,7 +17,11 @@ const upload = multer();
17
17
  app.use(express.json({limit: '500mb'}));
18
18
  app.use(express.urlencoded({extended: true, limit: '500mb'}));
19
19
  app.use(upload.any());
20
- app.use(cors());
20
+ app.use(cors({
21
+ origin: '*',
22
+ allowedHeaders: '*',
23
+ methods: '*'
24
+ }));
21
25
 
22
26
 
23
27
 
package/utils.js CHANGED
@@ -105,7 +105,6 @@ const socketSendByFilter = ({companyId, eventName, data, to, toId, excepts}, ser
105
105
 
106
106
  function findKeyByValue(map, targetKey, targetValue) {
107
107
  for (const item of map.values()) {
108
- console.log(item);
109
108
  if (item[targetKey] === targetValue) {
110
109
  return item;
111
110
  }