fix(wireguard): resolve empty auth token on client file upload
This commit is contained in:
parent
bd04298843
commit
787e3bb243
1 changed files with 3 additions and 15 deletions
|
|
@ -92,22 +92,10 @@ export async function uploadWgClientFile(id: number, file: File): Promise<any> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
// Direct fetch to bypass base JSON content-type overrides for multipart formdata
|
return await api.post({
|
||||||
const token = localStorage.getItem("token");
|
url: `/wireguard/client/${id}/files`,
|
||||||
const response = await fetch(`/api/wireguard/client/${id}/files`, {
|
data: formData
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token}`
|
|
||||||
},
|
|
||||||
body: formData
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const err = await response.json();
|
|
||||||
throw new Error(err.error?.message || "Upload failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function downloadWgClientFile(id: number, filename: string) {
|
export function downloadWgClientFile(id: number, filename: string) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue