Firebase 动态托管在区域更改后要求进行身份验证
Firebase dynamic hosting asks for authentication after region change
我使用云功能提供动态内容已有一段时间了。
现在,我尝试在函数构建器中使用 region()
来更改云函数的区域:
// Old
export const serveContent = functions
.https
.onRequest((req, res) => {...})
// New
export const serveContent = functions
.region("europe-west1")
.https
.onRequest((req, res) => {...})
在此更改期间,我没有在 firebase.json
中修改我的 rewrites
。
现在,请求不再到达云功能(日志中没有显示任何调用),我的浏览器被重定向到一个 302 Found
状态代码提示身份验证的页面。如何在没有身份验证的情况下继续提供内容?
编辑:
两个云函数都为 allUsers
设置了 Cloud Functions-Invoker
角色:
每次您在新区域部署函数时,Cloud Functions 都会创建一个完全不同的函数(除非指定),而不是修改之前的函数。看这里两个同名不同区域的函数是如何共存的:
因此,由于它是一个不同的函数,you need to configure the Access Control to it. Specifically, you can allow unauthenticated invocation for all users,但我强烈建议您查看这两个文档,因为它可能会因您的要求和 安全问题而发生变化.
另一方面,您的代码似乎有错字,但我相信这只是您的问题,而不是您的代码,因为您报告的错误完全不同。 如果是,请编辑您的问题。
// Old
export const serveContent = functions
.https
.onRequest((req, res) => {...})
// New
export const serveContent = function // <- Here. It should be 'functions', not function
.region("europe-west1")
.https
.onRequest((req, res) => {...})
身份验证提示只是实际问题的副作用。 The docs 状态:
Firebase Hosting supports Cloud Functions in us-central1 only.
我使用云功能提供动态内容已有一段时间了。
现在,我尝试在函数构建器中使用 region()
来更改云函数的区域:
// Old
export const serveContent = functions
.https
.onRequest((req, res) => {...})
// New
export const serveContent = functions
.region("europe-west1")
.https
.onRequest((req, res) => {...})
在此更改期间,我没有在 firebase.json
中修改我的 rewrites
。
现在,请求不再到达云功能(日志中没有显示任何调用),我的浏览器被重定向到一个 302 Found
状态代码提示身份验证的页面。如何在没有身份验证的情况下继续提供内容?
编辑:
两个云函数都为 allUsers
设置了 Cloud Functions-Invoker
角色:
每次您在新区域部署函数时,Cloud Functions 都会创建一个完全不同的函数(除非指定),而不是修改之前的函数。看这里两个同名不同区域的函数是如何共存的:
因此,由于它是一个不同的函数,you need to configure the Access Control to it. Specifically, you can allow unauthenticated invocation for all users,但我强烈建议您查看这两个文档,因为它可能会因您的要求和 安全问题而发生变化.
另一方面,您的代码似乎有错字,但我相信这只是您的问题,而不是您的代码,因为您报告的错误完全不同。 如果是,请编辑您的问题。
// Old
export const serveContent = functions
.https
.onRequest((req, res) => {...})
// New
export const serveContent = function // <- Here. It should be 'functions', not function
.region("europe-west1")
.https
.onRequest((req, res) => {...})
身份验证提示只是实际问题的副作用。 The docs 状态:
Firebase Hosting supports Cloud Functions in us-central1 only.