[bug] Fix wrong api calls for storeData

This commit is contained in:
Sosthene 2025-09-08 15:56:34 +02:00
parent e8c2d1a05a
commit 3f64369852

View File

@ -7,14 +7,13 @@ export async function storeData(servers: string[], key: string, value: Blob, ttl
let url: string;
if (server.startsWith('/')) {
// Relative path - construct manually for proxy
url = `${server}/store?key=${encodeURIComponent(key)}`;
url = `${server}/store/${encodeURIComponent(key)}`;
if (ttl !== null) {
url += `&ttl=${ttl}`;
url += `?ttl=${ttl}`;
}
} else {
// Absolute URL - use URL constructor
const urlObj = new URL(`${server}/store`);
urlObj.searchParams.append('key', key);
const urlObj = new URL(`${server}/store/${encodeURIComponent(key)}`);
if (ttl !== null) {
urlObj.searchParams.append('ttl', ttl.toString());
}