In my website it is working well in development, I mean in http://localhost:3000/ads.txt shows google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0 (see image)
However in production, I mean (in my case) https://zaraenlaparaibana.org/ads.txt it was downloading a txt file, and the content of the txt file was my index.html.
It was happening because of the redirects:
All paths are redirected to index.html is a common configuration in SPAs (Single Page Applications) to handle routing. This rule was causing the problem when I was trying to access the ads.txt file.
So, I update the _redirects to allow access to ads.txt without redirection:
The fact that the index.html file is being returned for that path indicates that the ads.txt file doesn’t exist in your Publish directory. Which is also confirmed by the other rule that you tried /ads.txt /ads.txt 200, as it cannot return a file it doesn’t have.
You should try running your Build command locally (not your Develop command), then check the build output in the folder that is your Publish directory (E.g. whatever folder your site builds into).
You will almost certainly find that the ads.txt file is not there, and thus not being deployed to Netlify.
You’ll then just need to adjust your build so that the file does end up in the build output.
Some build systems use a public folder for this, or you can otherwise move the file in there yourself post build.
The ads.txt was not in the publish directory. In my case, after running the build the ads.txt should be in dist folder, it was not there. After I put it in the public directory, the build was able to send it to dist folder. Thank you very much.