Hi,
I have static site build with netlify and it’s running. Lately, I want to host several audio file and use R2 bucket and use it with custom domain. Once I setup custom domain, cloudflare change cname record pointed to bucket. It work excellent. I can load the audio with custom domain. But the problem is, my static website is not working. I can’t add additional cname record pointed to default netlify record.
Which point that I missed? example: when user browse mydomain-com it served with static site by netlify. But when user download the audio, it served by R2. mydomain-com/audio.mp3
It sounds like you’ve set up a CNAME record for your custom domain that points to your R2 bucket, which is causing a conflict with your Netlify site. To serve both your static site and audio files under the same domain, you’ll need to configure subdomain routing. Here’s a step-by-step guide:
Create a subdomain for your audio files, such as audio.mydomain.com.
In your Cloudflare DNS settings, add a CNAME record for audio.mydomain.com pointing to your R2 bucket.
Keep your existing CNAME record for www.mydomain.com (or mydomain.com) pointing to Netlify.
Update your audio file links to use the new subdomain, like https://audio.mydomain.com/audio.mp3.
This way, your main domain will continue to serve your static site from Netlify, while the subdomain will serve your audio files from the R2 bucket.