[bug] Fix wrong api calls for storeData
This commit is contained in:
parent
e8c2d1a05a
commit
3f64369852
@ -7,14 +7,13 @@ export async function storeData(servers: string[], key: string, value: Blob, ttl
|
|||||||
let url: string;
|
let url: string;
|
||||||
if (server.startsWith('/')) {
|
if (server.startsWith('/')) {
|
||||||
// Relative path - construct manually for proxy
|
// Relative path - construct manually for proxy
|
||||||
url = `${server}/store?key=${encodeURIComponent(key)}`;
|
url = `${server}/store/${encodeURIComponent(key)}`;
|
||||||
if (ttl !== null) {
|
if (ttl !== null) {
|
||||||
url += `&ttl=${ttl}`;
|
url += `?ttl=${ttl}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Absolute URL - use URL constructor
|
// Absolute URL - use URL constructor
|
||||||
const urlObj = new URL(`${server}/store`);
|
const urlObj = new URL(`${server}/store/${encodeURIComponent(key)}`);
|
||||||
urlObj.searchParams.append('key', key);
|
|
||||||
if (ttl !== null) {
|
if (ttl !== null) {
|
||||||
urlObj.searchParams.append('ttl', ttl.toString());
|
urlObj.searchParams.append('ttl', ttl.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user