Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(mobile): validate server ping response body (#1459)

Corentin Thomasset9b8d9d70e8d8
diff --git a/.changeset/happy-books-taste.md b/.changeset/happy-books-taste.md
new file mode 100644
index 00000000..cedb1b47
--- /dev/null
+++ b/.changeset/happy-books-taste.md
@@ -0,0 +1,5 @@
+---
+'@papra/mobile': patch
+---
+
+Verify server initial ping response body to avoid interpreting 2xx responses that may be an auth proxy redirection.
diff --git a/apps/mobile/src/modules/config/config.services.ts b/apps/mobile/src/modules/config/config.services.ts
index 85c3375e..1e43e8ce 100644
--- a/apps/mobile/src/modules/config/config.services.ts
+++ b/apps/mobile/src/modules/config/config.services.ts
@@ -17,12 +17,12 @@ export async function pingServer({
url: string;
headers?: Record<string, string>;
}): Promise<true> {
- const response = await httpClient<{ status: 'ok' | 'error' }>({
+ const response = await httpClient<{ status: 'ok' }>({
url: `/api/ping`,
baseUrl: url,
headers,
})
- .then(() => true)
+ .then(({ status }) => status === 'ok')
.catch(() => false);
if (!response) {