@aurispec/core-backend 1.0.13 → 1.0.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../../src/common/configs/cors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;qBACH,MAAM,GAAG,SAAS,YACrB,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI;;;;;CAmB5D,CAAC"}
1
+ {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../../src/common/configs/cors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;qBACH,MAAM,GAAG,SAAS,YACrB,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI;;;;;CA6B5D,CAAC"}
@@ -2,16 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.corsOptions = void 0;
4
4
  const _1 = require(".");
5
+ const AppError_1 = require("../errors/AppError");
5
6
  exports.corsOptions = {
6
7
  origin: (origin, callback) => {
7
8
  let message = `Unathorized origins: ${origin}`;
8
9
  if (_1.CONFIGS.IS_PRODUCTION) {
9
- if (_1.CONFIGS.FRONT_ENDS.includes(origin || "")) {
10
+ if (!origin) {
11
+ return callback(new AppError_1.AppError(message), false);
12
+ }
13
+ const normalizedOrigin = origin.replace(/\/$/, "");
14
+ const allowedOrigins = _1.CONFIGS.FRONT_ENDS.map(o => o.replace(/\/$/, ""));
15
+ console.log({ normalizedOrigin });
16
+ console.log({ allowedOrigins });
17
+ console.log("CONFIGS.FRONT_ENDS", _1.CONFIGS.FRONT_ENDS);
18
+ if (allowedOrigins.includes(normalizedOrigin)) {
10
19
  callback(null, true);
11
20
  }
12
21
  else {
13
22
  _1.logger.error(message);
14
- callback(new Error(message), false);
23
+ callback(new AppError_1.AppError(message), false);
15
24
  }
16
25
  }
17
26
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurispec/core-backend",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Auri spectrum's backend core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",