fix(fetch): always use post http method

This commit is contained in:
Paul Chavard 2022-12-14 23:28:18 +01:00
parent b8ff0ba4a2
commit 17901d9be2
2 changed files with 7 additions and 7 deletions

View file

@ -134,9 +134,7 @@ export class AutosaveController extends ApplicationController {
private enqueueAutouploadRequest(target: HTMLInputElement, file: File) { private enqueueAutouploadRequest(target: HTMLInputElement, file: File) {
const autoupload = new AutoUpload(target, file); const autoupload = new AutoUpload(target, file);
try { autoupload.start().catch((e) => {
autoupload.start();
} catch (e) {
const error = e as FileUploadError; const error = e as FileUploadError;
// Report unexpected client errors to Sentry. // Report unexpected client errors to Sentry.
// (But ignore usual client errors, or errors we can monitor better on the server side.) // (But ignore usual client errors, or errors we can monitor better on the server side.)
@ -146,7 +144,7 @@ export class AutosaveController extends ApplicationController {
) { ) {
throw error; throw error;
} }
} });
} }
// Add a new autosave request to the queue. // Add a new autosave request to the queue.
@ -187,8 +185,9 @@ export class AutosaveController extends ApplicationController {
this.#pendingPromiseCount++; this.#pendingPromiseCount++;
return httpRequest(form.action, { return httpRequest(form.action, {
method: 'patch', method: 'post',
body: formData, body: formData,
headers: { 'x-http-method-override': 'PATCH' },
signal: this.#abortController.signal, signal: this.#abortController.signal,
timeout: AUTOSAVE_TIMEOUT_DELAY timeout: AUTOSAVE_TIMEOUT_DELAY
}).turbo(); }).turbo();

View file

@ -96,8 +96,9 @@ export default class Uploader {
try { try {
await httpRequest(autoAttachUrl, { await httpRequest(autoAttachUrl, {
method: 'put', method: 'post',
body: formData body: formData,
headers: { 'x-http-method-override': 'PUT' }
}).turbo(); }).turbo();
} catch (e) { } catch (e) {
const error = e as ResponseError; const error = e as ResponseError;