@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.
- package/lib/requestConfig.d.ts +3 -2
- package/lib/requestConfig.js +17 -23
- package/package.json +1 -1
package/lib/requestConfig.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ export type SSIRequestConfig = {
|
|
|
23
23
|
ssiClientId: string | null;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* Get the base URL from request headers
|
|
27
|
-
*
|
|
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. */
|
package/lib/requestConfig.js
CHANGED
|
@@ -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
|
|
18
|
-
*
|
|
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
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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) {
|