小编典典

如何使用带有Firebase托管的React在SPA上提供robots.txt?

reactjs

我有一个使用构建的SPA create-react-app,希望有一个robots.txt,如下所示:

http://example.com/robots.txt

我在此页面上看到:

在将服务器配置为从目录提供服务之后,您需要确保将服务器配置为捕获任何URL。

但是对于Firebase托管,我不确定该怎么办。


阅读 337

收藏
2020-07-22

共1个答案

小编典典

只需将以下规则添加到中的“重写”部分 firebase.json

"rewrites": [
      {
        "source": "/robots.txt",
        "destination": "/robots.txt"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
]
2020-07-22