More auth friendly ping URL
parent
891c8fb995
commit
a758446ecd
|
@ -6,7 +6,6 @@ export class HttpSpacePrimitives implements SpacePrimitives {
|
||||||
constructor(
|
constructor(
|
||||||
readonly url: string,
|
readonly url: string,
|
||||||
readonly expectedSpacePath?: string,
|
readonly expectedSpacePath?: string,
|
||||||
readonly syncMode = false,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +16,10 @@ export class HttpSpacePrimitives implements SpacePrimitives {
|
||||||
if (!options.headers) {
|
if (!options.headers) {
|
||||||
options.headers = {};
|
options.headers = {};
|
||||||
}
|
}
|
||||||
if (this.syncMode) {
|
options.headers = {
|
||||||
options.headers = { ...options.headers, ...{ "X-Sync-Mode": "true" } };
|
...options.headers,
|
||||||
}
|
"X-Sync-Mode": "true",
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await fetch(url, options);
|
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
|
// Used to check if the server is reachable and the user is authenticated
|
||||||
// If not: throws an error or invokes a redirect
|
// If not: throws an error or invokes a redirect
|
||||||
async ping() {
|
async ping() {
|
||||||
await this.authenticatedFetch(`${this.url}/SETTINGS.md`, { method: "GET" });
|
await this.authenticatedFetch(`${this.url}/index.json`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,6 @@ export class Client {
|
||||||
this.remoteSpacePrimitives = new HttpSpacePrimitives(
|
this.remoteSpacePrimitives = new HttpSpacePrimitives(
|
||||||
location.origin,
|
location.origin,
|
||||||
window.silverBulletConfig.spaceFolderPath,
|
window.silverBulletConfig.spaceFolderPath,
|
||||||
true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.plugSpaceRemotePrimitives = new PlugSpacePrimitives(
|
this.plugSpaceRemotePrimitives = new PlugSpacePrimitives(
|
||||||
|
|
Loading…
Reference in New Issue