@base44-preview/sdk 0.8.18-pr.90.f93cd0d → 0.8.18-pr.91.87dab3a

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.
@@ -45,29 +45,27 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
45
45
  window.location.href = loginUrl;
46
46
  },
47
47
  // Logout the current user
48
- // Removes the token from localStorage and optionally redirects to a URL or reloads the page
49
48
  logout(redirectUrl) {
50
- // Remove token from axios headers
49
+ // Remove token from axios headers (always do this)
51
50
  delete axios.defaults.headers.common["Authorization"];
52
- // Remove token from localStorage
53
- if (typeof window !== "undefined" && window.localStorage) {
54
- try {
55
- window.localStorage.removeItem("base44_access_token");
56
- // Remove "token" that is set by the built-in SDK of platform version 2
57
- window.localStorage.removeItem("token");
58
- }
59
- catch (e) {
60
- console.error("Failed to remove token from localStorage:", e);
61
- }
62
- }
63
- // Redirect if a URL is provided
51
+ // Only do the rest if in a browser environment
64
52
  if (typeof window !== "undefined") {
65
- if (redirectUrl) {
66
- window.location.href = redirectUrl;
67
- }
68
- else {
69
- window.location.reload();
53
+ // Remove token from localStorage
54
+ if (window.localStorage) {
55
+ try {
56
+ window.localStorage.removeItem("base44_access_token");
57
+ // Remove "token" that is set by the built-in SDK of platform version 2
58
+ window.localStorage.removeItem("token");
59
+ }
60
+ catch (e) {
61
+ console.error("Failed to remove token from localStorage:", e);
62
+ }
70
63
  }
64
+ // Determine the from_url parameter
65
+ const fromUrl = redirectUrl || window.location.href;
66
+ // Redirect to server-side logout endpoint to clear HTTP-only cookies
67
+ const logoutUrl = `${options.serverUrl}/api/apps/${appId}/auth/logout?from_url=${encodeURIComponent(fromUrl)}`;
68
+ window.location.href = logoutUrl;
71
69
  }
72
70
  },
73
71
  // Set authentication token
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.18-pr.90.f93cd0d",
3
+ "version": "0.8.18-pr.91.87dab3a",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",