mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 09:11:40 +08:00
parent
77807c4bb8
commit
2b19cf39e1
@ -6,6 +6,7 @@ import Translator from 'flarum/Translator';
|
||||
import extract from 'flarum/utils/extract';
|
||||
import patchMithril from 'flarum/utils/patchMithril';
|
||||
import RequestError from 'flarum/utils/RequestError';
|
||||
import { extend } from 'flarum/extend';
|
||||
|
||||
/**
|
||||
* The `App` class provides a container for an application, as well as various
|
||||
@ -189,6 +190,15 @@ export default class App {
|
||||
options.config = options.config || this.session.authorize.bind(this.session);
|
||||
options.background = options.background || true;
|
||||
|
||||
// If the method is something like PATCH or DELETE, which not all servers
|
||||
// support, then we'll send it as a POST request with a the intended method
|
||||
// specified in the X-Fake-Http-Method header.
|
||||
if (options.method !== 'GET' && options.method !== 'POST') {
|
||||
const method = options.method;
|
||||
extend(options, 'config', (result, xhr) => xhr.setRequestHeader('X-Fake-Http-Method', method));
|
||||
options.method = 'POST';
|
||||
}
|
||||
|
||||
// When we deserialize JSON data, if for some reason the server has provided
|
||||
// a dud response, we don't want the application to crash. We'll show an
|
||||
// error message to the user instead.
|
||||
|
Loading…
x
Reference in New Issue
Block a user