我在 Chrome 上有 CORS 扩展并且 GET 请求工作正常但 POST 请求没有。我收到错误“方法不允许”,但由于我有 CORS 扩展,根据文档,POST 请求应该可以工作。
我尝试使用另一个主题中提到的可选标头,但错误仍然存在。
我使用这个代码:
send(id){
let list = JSON.stringify(this.array)
this.http.post(this.url + this.id, list)
.subscribe(),
error => console.log("Error: ", error)
)
}
Run Code Online (Sandbox Code Playgroud)
浏览器控制台中的错误消息是:
消息:http://localhost:4000/ 的Http 失败响应...
名称:“HttpErrorResponse”
ok:false
status:405
statusText:“Method Not Allowed”