我有一个启用了CORS的Firebase功能,当我从我的网站使用其运行的firebase域从AJAX调用它时,但是,我已经在Firebase托管中设置了一个自定义域并重定向到功能域,在尝试之后我经历了由于重定向上删除了CORS头的一些问题,但是我如何在firebase托管域中实现CORS头是重定向?
解决方案是使用重写而不是重定向,这里是文档:
https://firebase.google.com/docs/hosting/functions#directing_hosting_requests_to_your_function
和一个示例firebase.json:
{ "hosting": { "public": "public", // Add the following rewrites section *within* "hosting" "rewrites": [ { "source": "/bigben", "function": "bigben" } ] } }
1 回答
解决方案是使用重写而不是重定向,这里是文档:
https://firebase.google.com/docs/hosting/functions#directing_hosting_requests_to_your_function
和一个示例firebase.json: