Redirect Firebase Hosting root to a Cloud Function is not working

前端 未结 1 1706
小蘑菇
小蘑菇 2021-02-08 14:47

I\'m using Firebase Hosting with a firebase.json file that is supposed to forward all traffic to a cloud function (prerender) which populates meta and og tags for S

相关标签:
1条回答
  • 2021-02-08 15:20

    You should be able to route all URLs to a function in exactly the way you're showing. I'm guessing that you still have an index.html file located in your dist/prod directory. In my test project, I simply renamed the root index.html to something else, and requests to / were routed to my function.

    It turns out that if there is static web content that matches the client request URL, that will be served instead of delegating to the function. This is true for any incoming URL. The only way to truly ensure that all requests are routed to your function is to remove all content from your dist/prod folder before deploying.

    I believe the key piece of information is in the documentation for rewrites:

    A rewrite rule is only applied if a file or folder does not exist at the specified source, and returns the actual content of the file at the destination instead of an HTTP redirect.

    0 讨论(0)
提交回复
热议问题