How can I serve robots.txt on an SPA using React with Firebase hosting?

后端 未结 2 540
谎友^
谎友^ 2021-02-07 23:33

I have an SPA built using create-react-app and wish to have a robots.txt like this:

http://example.com/robots.txt

I see on this pa

2条回答
  •  攒了一身酷
    2021-02-07 23:45

    Just add the following rules to the "rewrites" section in firebase.json

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

提交回复
热议问题