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 page that:
You need to make sure your server is configured to catch any URL after it's configured to serve from a directory.
But for firebase hosting, I'm not sure what to do.
In my
/public
directory, I created arobots.txt
.In my
/src
directory, I did the following:I created
/src/index.js
:I created
/src/TopApp.js
:Because path
/robots.txt
is not covered by the router paths provided, it took it from my public directory and robots file was published as desired.The same could be done for
sitemap.xml
.