@jaypie/express 1.2.34 → 1.2.35

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,10 +1,11 @@
1
1
  import type { Request, Response, NextFunction } from "express";
2
+ export type CorsOrigin = string | RegExp | Array<string | RegExp>;
2
3
  export interface CorsConfig {
3
- origin?: string | string[];
4
+ origin?: CorsOrigin;
4
5
  overrides?: Record<string, unknown>;
5
6
  }
6
7
  type CorsCallback = (err: Error | null, allow?: boolean) => void;
7
- export declare const dynamicOriginCallbackHandler: (origin?: string | string[]) => ((requestOrigin: string | undefined, callback: CorsCallback) => void);
8
+ export declare const dynamicOriginCallbackHandler: (origin?: CorsOrigin) => ((requestOrigin: string | undefined, callback: CorsCallback) => void);
8
9
  /**
9
10
  * CORS middleware with Lambda streaming support.
10
11
  *
@@ -1301,8 +1301,9 @@ const dynamicOriginCallbackHandler = (origin) => {
1301
1301
  const additionalOrigins = kit.force.array(origin);
1302
1302
  allowedOrigins.push(...additionalOrigins);
1303
1303
  }
1304
- // Add localhost origins in sandbox
1305
- if (process.env.PROJECT_ENV === SANDBOX_ENV ||
1304
+ // Add localhost origins in local and sandbox environments
1305
+ if (kit.isLocalEnv() ||
1306
+ process.env.PROJECT_ENV === SANDBOX_ENV ||
1306
1307
  kit.envBoolean("PROJECT_SANDBOX_MODE")) {
1307
1308
  allowedOrigins.push("http://localhost");
1308
1309
  allowedOrigins.push(/^http:\/\/localhost:\d+$/);