I would like a DNS record that does not point to any origin but redirects to a URL either with 301 or 302 status code, optionally preserving path.
DNS doesn’t do paths…only Domains. So, what I do is create a “dummy” DNS A Record for that domain. Use the IP address of your target domain (it won’t be live, it’s just a placeholder).
Once that’s done, use Page Rules that will do the redirect you want.
This is what I currently do, but I want a more clean solution.
To do what you specifically asked, there is no other option. DNS is like a phone book… absent a DNS entry it’s like looking up a business and not finding it there. You can’t redirect it somewhere else.
Depending on what you are trying to achieve however a CNAME could also be an option, that is an alias of one host name to another. So foo.example.com can point to bar.example.com and as long as bar is cool with being called foo it should work as expected.
At least I would like a dummy record option for requests fully handled by CloudFlare page rules.