@base44-preview/sdk 0.8.27-pr.170.be14e2c → 0.8.27-pr.171.bb56537
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 +10 -8
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -112,6 +112,16 @@ export function createClient(config) {
|
|
|
112
112
|
appBaseUrl: normalizedAppBaseUrl,
|
|
113
113
|
serverUrl,
|
|
114
114
|
});
|
|
115
|
+
// Apply the access token before any module that may issue authenticated
|
|
116
|
+
// requests during construction (notably analytics, which fires an init
|
|
117
|
+
// event whose flush calls auth.me()). Without this, the first User/me
|
|
118
|
+
// request is built before setToken runs and goes out unauthenticated.
|
|
119
|
+
if (typeof window !== "undefined") {
|
|
120
|
+
const accessToken = token || getAccessToken();
|
|
121
|
+
if (accessToken) {
|
|
122
|
+
userAuthModule.setToken(accessToken);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
115
125
|
const userModules = {
|
|
116
126
|
entities: createEntitiesModule({
|
|
117
127
|
axios: axiosClient,
|
|
@@ -189,14 +199,6 @@ export function createClient(config) {
|
|
|
189
199
|
}
|
|
190
200
|
},
|
|
191
201
|
};
|
|
192
|
-
// Always try to get token from localStorage or URL parameters
|
|
193
|
-
if (typeof window !== "undefined") {
|
|
194
|
-
// Get token from URL or localStorage
|
|
195
|
-
const accessToken = token || getAccessToken();
|
|
196
|
-
if (accessToken) {
|
|
197
|
-
userModules.auth.setToken(accessToken);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
202
|
// If authentication is required, verify token and redirect to login if needed
|
|
201
203
|
if (requiresAuth && typeof window !== "undefined") {
|
|
202
204
|
// We perform this check asynchronously to not block client creation
|