Apply CDN to my website via different URL

I want to understand / replicate the setup of another website where the CDN is provided by a different domain than the actual site.

Let me explain,

The website is on domain1.com and i the cdn setup with cloudflare is on domain2.com.

When i visit domain2 i get automatically redirected to domain1 where the actual website is. When i look up the nameservers on domain1 i do not see cloudflare, i see private nameservers being provided by namecheap. However when i do a webpagetest lookup i can see that the CDN for domain1 is being provided by cloudflare via domain2.

So if anybody looks up domain1 they do not see cloudflare nameservers instead they see namecheaps private dns.

Does that make sense? How can i set up the same or similar?

Cloudflare is designed to proxy your standalone site. If you want to split your content between two domains, I suggest you find a web developer who can configure this specialized configuration for you.

Cloudflare really has no bearing on this configuration. That setup will have to work regardless of Cloudflare’s involvement.

p.s. If your goal is just to have Cloudflare act as a CDN for media files, you’ll be in violation of Terms of Service 2.8.