admin管理员组文章数量:1279124
I have a Firebase Callable Cloud Function which I call in my javascript app in the browser.
Because the request host is ...cloudfunctions and not my app domain this results in a CORS preflight OPTIONS request before the real POST request.
If this was a function with http trigger I'd avoid the extra time that the preflight takes by specifying my function as a rewrite in my hosting config and sending the request to the same domain my app is hosted on.
Is there any way to avoid this preflight with Firebase Callable Cloud Functions? Perhaps there's a way to proxy the request through Firebase Hosting, like you can with http Cloud Functions
I have a Firebase Callable Cloud Function which I call in my javascript app in the browser.
Because the request host is ...cloudfunctions and not my app domain this results in a CORS preflight OPTIONS request before the real POST request.
If this was a function with http trigger I'd avoid the extra time that the preflight takes by specifying my function as a rewrite in my hosting config and sending the request to the same domain my app is hosted on.
Is there any way to avoid this preflight with Firebase Callable Cloud Functions? Perhaps there's a way to proxy the request through Firebase Hosting, like you can with http Cloud Functions
Share Improve this question edited Mar 26, 2019 at 9:17 Jake asked Mar 26, 2019 at 8:32 JakeJake 13.2k19 gold badges70 silver badges97 bronze badges 5- "Normally I'd avoid the extra time that the preflight takes by specifying my function as a rewrite in my hosting config and sending the request to the same domain my app is hosted on." -> So why not this time? – Daniel Hilgarth Commented Mar 26, 2019 at 8:34
-
2
That works for
functions.https.onRequest
because I can specify the host. This question is about Firebase Callable Cloud Functions – Jake Commented Mar 26, 2019 at 9:12 - 2 Why the downvotes? – Jake Commented Mar 26, 2019 at 9:18
- 2 I didn't downvote – Daniel Hilgarth Commented Mar 26, 2019 at 9:45
- Make sure the function name referenced in the client is correct, see stackoverflow./a/62042554/1030246 – tazmaniax Commented May 14, 2021 at 15:37
5 Answers
Reset to default 9After bing through Firebase docs and JS SDK source I've decided this is not possible without using/overriding private APIs.
The solution I've used is to replicate the JS SDK code but specifying a URL that goes via Firebase Hosting so it's on the same domain as my app.
Same Cloud Function, same app code, no CORS preflight
本文标签: javascriptAvoid CORS preflight for Firebase callable functionStack Overflow
版权声明:本文标题:javascript - Avoid CORS preflight for Firebase callable function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741214408a2359766.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论