@base44-preview/sdk 0.8.17-pr.77.cbf4b6e → 0.8.17-pr.77.dfc0f63
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/dist/modules/auth.js +9 -1
- package/package.json +1 -1
package/dist/modules/auth.js
CHANGED
|
@@ -33,8 +33,16 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
33
33
|
const redirectUrl = nextUrl
|
|
34
34
|
? new URL(nextUrl, window.location.origin).toString()
|
|
35
35
|
: window.location.href;
|
|
36
|
+
// For preview URLs (preview--*), redirect to main app's login page
|
|
37
|
+
// but keep from_url pointing to the preview URL
|
|
38
|
+
let loginBaseUrl = (_a = options.appBaseUrl) !== null && _a !== void 0 ? _a : "";
|
|
39
|
+
const hostname = window.location.hostname;
|
|
40
|
+
if (hostname.startsWith("preview--")) {
|
|
41
|
+
const mainHostname = hostname.replace(/^preview--/, "");
|
|
42
|
+
loginBaseUrl = `${window.location.protocol}//${mainHostname}${window.location.port ? ":" + window.location.port : ""}`;
|
|
43
|
+
}
|
|
36
44
|
// Build the login URL
|
|
37
|
-
const loginUrl = `${
|
|
45
|
+
const loginUrl = `${loginBaseUrl}/login?from_url=${encodeURIComponent(redirectUrl)}`;
|
|
38
46
|
// Redirect to the login page
|
|
39
47
|
window.location.href = loginUrl;
|
|
40
48
|
},
|