@nest-omni/core 1.0.55 → 1.0.56-1

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": "@nest-omni/core",
3
- "version": "1.0.55",
3
+ "version": "1.0.56-1",
4
4
  "description": "framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,6 +23,7 @@ const nestjs_sentry_1 = require("@ntegral/nestjs-sentry");
23
23
  const nestjs_i18n_1 = require("nestjs-i18n");
24
24
  const crud_1 = require("@dataui/crud");
25
25
  const nestjs_cls_1 = require("nestjs-cls");
26
+ const compression = require("compression");
26
27
  crud_1.CrudConfigService.load({
27
28
  auth: {
28
29
  property: 'user',
@@ -124,7 +125,7 @@ function bootstrapSetup(AppModule, SetupSwagger) {
124
125
  setupGracefulShutdown(app);
125
126
  app.enableVersioning();
126
127
  app.enable('trust proxy');
127
- app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)());
128
+ app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)(), compression());
128
129
  const reflector = app.get(core_1.Reflector);
129
130
  app.useGlobalFilters(new __1.HttpExceptionFilter(), new __1.QueryFailedFilter(reflector));
130
131
  app.useGlobalInterceptors(new __1.LanguageInterceptor(), new __1.TranslationInterceptor(), new nestjs_pino_1.LoggerErrorInterceptor(), new nestjs_sentry_1.SentryInterceptor({
@@ -159,13 +159,23 @@ let ApiConfigService = ApiConfigService_1 = class ApiConfigService {
159
159
  const allowedDomains = this.getString('CORS_ORIGIN').split(',');
160
160
  return {
161
161
  origin: (origin, callback) => {
162
- if (!origin ||
163
- allowedDomains.some((domain) => origin.endsWith(domain))) {
164
- callback(null, origin);
165
- }
166
- else {
167
- callback(new common_1.BadRequestException('Not allowed by CORS'));
162
+ if (!origin) {
163
+ return callback(null, true);
168
164
  }
165
+ const isAllowed = allowedDomains.some((domain) => {
166
+ if (domain.includes('*')) {
167
+ const regexPattern = domain
168
+ .replace(/\./g, '\\.')
169
+ .replace(':*', '(:\\d+)?')
170
+ .replace('*\\.', '(.*\\.)?');
171
+ const fullRegex = new RegExp(`^https?:\/\/${regexPattern}$`, 'i');
172
+ return fullRegex.test(origin);
173
+ }
174
+ return origin === domain || origin.startsWith(`${domain}:`);
175
+ });
176
+ isAllowed
177
+ ? callback(null, origin)
178
+ : callback(new common_1.BadRequestException('Not allowed by CORS'));
169
179
  },
170
180
  methods: this.getString('CORS_METHODS'),
171
181
  allowedHeaders: this.getString('CORS_ALLOWED_HEADERS'),