mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-12 20:40:52 +00:00
fix: keep bootstrap in url for app to do whatever (#2648)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
* fix: only set authToken if present for apps * fix: keep bootstrap in url for app to do whatever
This commit is contained in:
@@ -340,27 +340,9 @@ const puterInit = (function () {
|
||||
const bootstrapAuthToken = normalizeAuthTokenCandidate(
|
||||
URLParams.get('puter.auth.token') ?? URLParams.get('auth_token'),
|
||||
);
|
||||
this.authToken = bootstrapAuthToken;
|
||||
// initialize submodules
|
||||
this.initSubmodules();
|
||||
try {
|
||||
if ( bootstrapAuthToken ) {
|
||||
this.setAuthToken(bootstrapAuthToken);
|
||||
|
||||
// Token-in-query is bootstrap-only; persist it then scrub from URL.
|
||||
if ( globalThis.history?.replaceState && globalThis.location?.href ) {
|
||||
const currentUrl = new URL(globalThis.location.href);
|
||||
const hadBootstrapToken =
|
||||
currentUrl.searchParams.has('puter.auth.token')
|
||||
|| currentUrl.searchParams.has('auth_token');
|
||||
if ( hadBootstrapToken ) {
|
||||
currentUrl.searchParams.delete('puter.auth.token');
|
||||
currentUrl.searchParams.delete('auth_token');
|
||||
const currentUrlSearch = currentUrl.searchParams.toString();
|
||||
const sanitizedRelativeUrl = `${currentUrl.pathname}${currentUrlSearch ? `?${currentUrlSearch}` : ''}${currentUrl.hash || ''}`;
|
||||
globalThis.history.replaceState(globalThis.history.state, '', sanitizedRelativeUrl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const storedAuthToken = normalizeAuthTokenCandidate(
|
||||
localStorage.getItem('puter.auth.token'),
|
||||
@@ -379,6 +361,7 @@ const puterInit = (function () {
|
||||
// Handle the error here
|
||||
console.error('Error accessing localStorage:', error);
|
||||
}
|
||||
this.initSubmodules();
|
||||
}
|
||||
// SDK was loaded in a 3rd-party website.
|
||||
// When SDK is loaded in GUI the initiation process should start when the DOM is ready. This is because
|
||||
|
||||
Reference in New Issue
Block a user