Firebase 函数 - DELETE 请求在 firebaseapp 域上没有正文参数
Firebase functions - DELETE request has no body params on firebaseapp domain
我将我的一个 Express 应用程序迁移到了 Firebase 函数。除了具有表单正文的 DELETE 请求外,一切都完美无缺。当我直接在此 url
上访问我的函数时
https://us-central1-[appname].cloudfunctions.net/app/api/hidden
并发送带有表单正文的删除请求一切正常。但是当我尝试这个 url
这应该以相同的方式运行,我的应用程序崩溃了,因为请求的正文是空的。出于某种原因,我无法在第二个 url 上发送带有正文的 DELETE 请求。有人遇到过这个问题吗?
我的 fireabse.json 看起来像这样
{
"hosting": {
"rewrites":[{
"source": "**",
"function": "app"
}]
//other rules
}
}
我给 firebase 支持发了邮件,他们回复了一个答案。 Firebase 应用基本上不支持删除请求。引用:
...connecting Cloud Functions with Hosting is intended to serve dynamic content, that being said on your current implementation I would suggest to use the cloud functions URL only for the delete request (to preserve the caching advantages on other types of requests). Another option would be not to use the payload from the body since the HTTP 1.1 spec warns about using it “sending a payload body on a DELETE request might cause some existing implementations to reject the request”.
我将我的一个 Express 应用程序迁移到了 Firebase 函数。除了具有表单正文的 DELETE 请求外,一切都完美无缺。当我直接在此 url
上访问我的函数时https://us-central1-[appname].cloudfunctions.net/app/api/hidden
并发送带有表单正文的删除请求一切正常。但是当我尝试这个 url
这应该以相同的方式运行,我的应用程序崩溃了,因为请求的正文是空的。出于某种原因,我无法在第二个 url 上发送带有正文的 DELETE 请求。有人遇到过这个问题吗?
我的 fireabse.json 看起来像这样
{
"hosting": {
"rewrites":[{
"source": "**",
"function": "app"
}]
//other rules
}
}
我给 firebase 支持发了邮件,他们回复了一个答案。 Firebase 应用基本上不支持删除请求。引用:
...connecting Cloud Functions with Hosting is intended to serve dynamic content, that being said on your current implementation I would suggest to use the cloud functions URL only for the delete request (to preserve the caching advantages on other types of requests). Another option would be not to use the payload from the body since the HTTP 1.1 spec warns about using it “sending a payload body on a DELETE request might cause some existing implementations to reject the request”.