@serialsubscriptions/platform-integration 0.0.8-5.1 → 0.0.8-5.2

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.
@@ -23,8 +23,9 @@ export type SSIRequestConfig = {
23
23
  ssiClientId: string | null;
24
24
  };
25
25
  /**
26
- * Get the base URL from request headers or environment.
27
- * Uses x-forwarded-proto, x-forwarded-host, origin, host, and NEXT_PUBLIC_APP_URL.
26
+ * Get the base URL from environment or request headers.
27
+ * If NEXT_PUBLIC_APP_URL is set, returns it; otherwise derives from
28
+ * x-forwarded-proto, x-forwarded-host, origin, or host.
28
29
  */
29
30
  export declare function getBaseUrl(req: Request): string | null;
30
31
  /** When baseUrl is a single URL or comma-separated list, return the first URL. */
@@ -14,32 +14,26 @@ exports.toAuthConfig = toAuthConfig;
14
14
  exports.normalizeAuthConfig = normalizeAuthConfig;
15
15
  // --- Helpers used by getRequestConfig (env: NEXT_PUBLIC_APP_URL, SSI_*, request headers) ---
16
16
  /**
17
- * Get the base URL from request headers or environment.
18
- * Uses x-forwarded-proto, x-forwarded-host, origin, host, and NEXT_PUBLIC_APP_URL.
17
+ * Get the base URL from environment or request headers.
18
+ * If NEXT_PUBLIC_APP_URL is set, returns it; otherwise derives from
19
+ * x-forwarded-proto, x-forwarded-host, origin, or host.
19
20
  */
20
21
  function getBaseUrl(req) {
22
+ const fromEnv = process.env.NEXT_PUBLIC_APP_URL?.trim();
23
+ if (fromEnv)
24
+ return fromEnv;
21
25
  const proto = req.headers.get('x-forwarded-proto') || 'https';
22
- let baseUrl = process.env.NEXT_PUBLIC_APP_URL;
23
- if (!baseUrl) {
24
- const forwardedHost = req.headers.get('x-forwarded-host');
25
- if (forwardedHost) {
26
- baseUrl = `${proto}://${forwardedHost}`;
27
- }
28
- else {
29
- const origin = req.headers.get('origin');
30
- if (origin) {
31
- baseUrl = origin;
32
- }
33
- else {
34
- const host = req.headers.get('host');
35
- const hostWithoutPort = host ? host.split(':')[0] : undefined;
36
- if (hostWithoutPort) {
37
- baseUrl = `${proto}://${hostWithoutPort}`;
38
- }
39
- }
40
- }
41
- }
42
- return baseUrl || null;
26
+ const forwardedHost = req.headers.get('x-forwarded-host');
27
+ if (forwardedHost)
28
+ return `${proto}://${forwardedHost}`;
29
+ const origin = req.headers.get('origin');
30
+ if (origin)
31
+ return origin;
32
+ const host = req.headers.get('host');
33
+ const hostWithoutPort = host ? host.split(':')[0] : undefined;
34
+ if (hostWithoutPort)
35
+ return `${proto}://${hostWithoutPort}`;
36
+ return null;
43
37
  }
44
38
  /** When baseUrl is a single URL or comma-separated list, return the first URL. */
45
39
  function firstBaseUrl(baseUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serialsubscriptions/platform-integration",
3
- "version": "0.0.85.1",
3
+ "version": "0.0.85.2",
4
4
  "description": "Serial Subscriptions Libraries",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",