fix upload urls

This commit is contained in:
Felix Ableitner 2024-12-17 11:06:07 +01:00
parent 42bac94699
commit 4bf613ef68

View file

@ -176,7 +176,6 @@ type RequestOptions = Pick<RequestInit, "signal">;
export class LemmyHttp { export class LemmyHttp {
#apiUrl: string; #apiUrl: string;
#headers: { [key: string]: string } = {}; #headers: { [key: string]: string } = {};
#pictrsUrl: string;
#fetchFunction: typeof fetch = fetch.bind(globalThis); #fetchFunction: typeof fetch = fetch.bind(globalThis);
/** /**
@ -192,7 +191,6 @@ export class LemmyHttp {
}, },
) { ) {
this.#apiUrl = `${baseUrl.replace(/\/+$/, "")}/api/${VERSION}`; this.#apiUrl = `${baseUrl.replace(/\/+$/, "")}/api/${VERSION}`;
this.#pictrsUrl = `${baseUrl}/pictrs/image`;
if (options?.headers) { if (options?.headers) {
this.#headers = options.headers; this.#headers = options.headers;
@ -1881,7 +1879,7 @@ export class LemmyHttp {
): Promise<UploadImageResponse> { ): Promise<UploadImageResponse> {
const formData = createFormData(image); const formData = createFormData(image);
const response = await this.#fetchFunction(this.#pictrsUrl, { const response = await this.#fetchFunction("/api/v4/image", {
...options, ...options,
method: HttpType.Post, method: HttpType.Post,
body: formData as unknown as BodyInit, body: formData as unknown as BodyInit,
@ -1901,7 +1899,7 @@ export class LemmyHttp {
): Promise<SuccessResponse> { ): Promise<SuccessResponse> {
const formData = createFormData(image); const formData = createFormData(image);
const response = await this.#fetchFunction(this.#pictrsUrl, { const response = await this.#fetchFunction("/api/v4/account/avatar", {
...options, ...options,
method: HttpType.Post, method: HttpType.Post,
body: formData as unknown as BodyInit, body: formData as unknown as BodyInit,