From a758446ecd80d70ce6b7a1ff0dba0da6ca4cd06d Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 28 Jul 2023 15:34:12 +0200 Subject: [PATCH] More auth friendly ping URL --- common/spaces/http_space_primitives.ts | 15 ++++++++++----- web/client.ts | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/spaces/http_space_primitives.ts b/common/spaces/http_space_primitives.ts index 6a6dc987..c983d740 100644 --- a/common/spaces/http_space_primitives.ts +++ b/common/spaces/http_space_primitives.ts @@ -6,7 +6,6 @@ export class HttpSpacePrimitives implements SpacePrimitives { constructor( readonly url: string, readonly expectedSpacePath?: string, - readonly syncMode = false, ) { } @@ -17,9 +16,10 @@ export class HttpSpacePrimitives implements SpacePrimitives { if (!options.headers) { options.headers = {}; } - if (this.syncMode) { - options.headers = { ...options.headers, ...{ "X-Sync-Mode": "true" } }; - } + options.headers = { + ...options.headers, + "X-Sync-Mode": "true", + }; try { const result = await fetch(url, options); @@ -163,6 +163,11 @@ export class HttpSpacePrimitives implements SpacePrimitives { // Used to check if the server is reachable and the user is authenticated // If not: throws an error or invokes a redirect async ping() { - await this.authenticatedFetch(`${this.url}/SETTINGS.md`, { method: "GET" }); + await this.authenticatedFetch(`${this.url}/index.json`, { + method: "GET", + headers: { + Accept: "application/json", + }, + }); } } diff --git a/web/client.ts b/web/client.ts index d6c80c37..977e46bf 100644 --- a/web/client.ts +++ b/web/client.ts @@ -274,7 +274,6 @@ export class Client { this.remoteSpacePrimitives = new HttpSpacePrimitives( location.origin, window.silverBulletConfig.spaceFolderPath, - true, ); this.plugSpaceRemotePrimitives = new PlugSpacePrimitives(