Use this guide when you want document file URLs, such as PDFs, to resolve from your site domain instead of static-cdn.publive.online.
Problem statement
Your published content may contain document URLs that point to the Publive CDN domain. If you want those PDFs and similar files to be served from your own domain, you need a route on your app that forwards the request to Publive and returns the file response.
What you are doing
You will create a Next.js proxy route at /api/files/* and expose it through /files/* using a rewrite rule. The route accepts document file paths, fetches the file from Publive CDN, and returns it from your domain.
After setup, a URL like:
https://static-cdn.publive.online/path/to/brochure.pdf
becomes:
https://your-domain.com/files/path/to/brochure.pdf
1. Create an API proxy route
Create pages/api/files/[...path].ts:
2. Add a rewrite for /files/*
Add this to next.config.js:
3. Use /files/ URLs in your frontend
Use /files/... anywhere you render file URLs.
Example:
- Input:
https://static-cdn.publive.online/documents/abc.pdf
- Output:
/files/documents/abc.pdf
4. Verify locally
- Run your Next.js app.
- Open a known file URL:
http://localhost:3000/files/path/to/file.pdf.
- Confirm the response is
200 and comes from your domain.
Notes
- Keep this proxy server-side only.
- If you want CDN caching behavior, do not force
cache-control: no-store on forwarded headers.
- If you deploy behind another CDN, configure caching there as needed.
Last modified on July 21, 2026