@base44-preview/sdk 0.8.17-pr.77.dfc0f63 → 0.8.17-pr.77.f633c05

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/client.js CHANGED
@@ -167,9 +167,7 @@ export function createClient(config) {
167
167
  }
168
168
  }
169
169
  // If authentication is required, verify token and redirect to login if needed
170
- // Skip if already on login page to avoid redirect loop
171
- const isOnLoginPage = typeof window !== "undefined" && window.location.pathname === "/login";
172
- if (requiresAuth && typeof window !== "undefined" && !isOnLoginPage) {
170
+ if (requiresAuth && typeof window !== "undefined") {
173
171
  // We perform this check asynchronously to not block client creation
174
172
  setTimeout(async () => {
175
173
  try {
@@ -25,8 +25,10 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
25
25
  if (typeof window === "undefined") {
26
26
  throw new Error("Login method can only be used in a browser environment");
27
27
  }
28
- // Skip redirect if already on login page to avoid redirect loop
29
- if (window.location.pathname === "/login") {
28
+ const hostname = window.location.hostname;
29
+ const isPreview = hostname.startsWith("preview--");
30
+ // Skip redirect if already on login page (but not on preview - preview should redirect to main app)
31
+ if (window.location.pathname === "/login" && !isPreview) {
30
32
  return;
31
33
  }
32
34
  // If nextUrl is not provided, use the current URL
@@ -36,8 +38,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
36
38
  // For preview URLs (preview--*), redirect to main app's login page
37
39
  // but keep from_url pointing to the preview URL
38
40
  let loginBaseUrl = (_a = options.appBaseUrl) !== null && _a !== void 0 ? _a : "";
39
- const hostname = window.location.hostname;
40
- if (hostname.startsWith("preview--")) {
41
+ if (isPreview) {
41
42
  const mainHostname = hostname.replace(/^preview--/, "");
42
43
  loginBaseUrl = `${window.location.protocol}//${mainHostname}${window.location.port ? ":" + window.location.port : ""}`;
43
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.17-pr.77.dfc0f63",
3
+ "version": "0.8.17-pr.77.f633c05",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",