Google allows the robots.txt
301 redirection you're talking about:
Google follows at least five redirect hops as defined by RFC 1945 for HTTP/1.0 and then stops and treats it as a 404.
https://developers.google.com/search/reference/robots_txt
I couldn't find any information about Bing's crawler.
It's my suspicion that smaller, poorly-written, non-search-engine bots might not be smart enough to follow the redirect, and might take the 301 status code as a blank check to hit your website.
If this is about keeping your robots.txt
automatically up to date with the robots.txt
on the other domain, I'd consider a reverse-proxy setup if possible.
On the other hand if this is about lessening the strain on your server by offloading your robots.txt
to a CDN, well, your server is still going to have to serve all of those 301 status codes, which probably won't be much of a lighter load than just serving up the robots.txt
file in the first place. And if serving your robots.txt
file even tens of thousands of times per day is putting any real strain on your server, that's a surefire sign that there's an issue with your server.