Tag: fetch api

不允许获取补丁请求

我有两个应用程序,一个是反应前端,第二个是rails-api应用程序。 我一直很高兴使用isomorphic-fetch,直到我需要将PATCH方法发送到服务器。 我正进入(状态: Fetch API cannot load http://localhost:3000/api/v1/tasks. Method patch is not allowed by Access-Control-Allow-Methods in preflight response. 但来自服务器的OPTIONS响应包括Access-Control-Allow-Methods列表中的PATCH方法: 这是fetch的实现方式: 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设置几乎相同,它们工作正常。 知道这里发生了什么吗? 更新: 方法补丁区分大小写: […]