Fetch Patch Request ist nicht erlaubt

Ich habe zwei Apps, eine ist ein React Front-End und die zweite ist die Rails-API-App.

Ich habe glücklich mit isomorphic-fetch, bis ich die PATCH-Methode an den Server senden musste.

Ich bekomme

Fetch API cannot load http://localhost:3000/api/v1/tasks. Method patch is not allowed by Access-Control-Allow-Methods in preflight response.

Die Antwort OPTIONS vom Server enthält jedoch eine PATCH-Methode in einer Liste von Zugriffskontroll-Zulassungsmethoden:

So wird der Abruf implementiert:

const API_URL = 'http://localhost:3000/'                                            
const API_PATH = 'api/v1/'

fetch(API_URL + API_PATH + 'tasks', {
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  method: 'patch',                                                              
  body: JSON.stringify( { task: task } )                                        
})

POST, GET, DELETE sind fast gleich eingerichtet und funktionieren einwandfrei.

Keine Ahnung, was hier los ist?

AKTUALISIEREN

Method Patch unterscheidet zwischen Groß- und Kleinschreibung:

https: //github.com/github/fetch/blob/master/fetch.js#L20

Nicht sicher, ob dies beabsichtigt oder ein Fehler ist.

UPDATE 2

Dies ist beabsichtigt und der Methodentyp PATCH muss zwischen Groß- und Kleinschreibung unterscheiden. Aktualisieren der Zeile von der Abrufmethode auf:

method: 'PATCH'

behebt das Problem.

https: //github.com/github/fetch/issues/25

Antworten auf die Frage(6)

Ihre Antwort auf die Frage