astro-tractstack 2.0.36 → 2.0.37
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/package.json
CHANGED
|
@@ -212,16 +212,35 @@ const enableBunny = import.meta.env.PUBLIC_ENABLE_BUNNY === 'true';
|
|
|
212
212
|
// This makes the scope explicit and resolves the linter error.
|
|
213
213
|
const initialStoryfragmentId = storyfragmentId;
|
|
214
214
|
const initialSessionId = sessionId;
|
|
215
|
-
|
|
216
215
|
function updateTractstackConfig() {
|
|
217
216
|
const storyfragmentMeta = document.querySelector(
|
|
218
217
|
'meta[name="storyfragment-id"]'
|
|
219
218
|
);
|
|
220
219
|
const sessionMeta = document.querySelector('meta[name="session-id"]');
|
|
221
220
|
|
|
221
|
+
// Dynamic Backend URL Fix:
|
|
222
|
+
// If we are on a subdomain (sandbox.domain.com), force the API call to match
|
|
223
|
+
// (sandbox.domain.com:10000) so cookies are sent correctly.
|
|
224
|
+
let dynamicBackendUrl = goBackend;
|
|
225
|
+
try {
|
|
226
|
+
const currentHost = window.location.hostname;
|
|
227
|
+
const backendUrlObj = new URL(goBackend);
|
|
228
|
+
|
|
229
|
+
// If the hostnames differ (e.g. sandbox.site.com vs site.com), align them
|
|
230
|
+
if (currentHost !== backendUrlObj.hostname) {
|
|
231
|
+
backendUrlObj.hostname = currentHost;
|
|
232
|
+
dynamicBackendUrl = backendUrlObj.toString().replace(/\/$/, '');
|
|
233
|
+
}
|
|
234
|
+
} catch (e) {
|
|
235
|
+
console.warn(
|
|
236
|
+
'TractStack: Failed to construct dynamic backend URL',
|
|
237
|
+
e
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
222
241
|
window.TRACTSTACK_CONFIG = {
|
|
223
242
|
configured: true,
|
|
224
|
-
backendUrl:
|
|
243
|
+
backendUrl: dynamicBackendUrl,
|
|
225
244
|
tenantId: tenantId,
|
|
226
245
|
fontBasePath: fontBasePath,
|
|
227
246
|
// Use the meta tag if it exists (for subsequent client-side loads),
|