A simple serverless API that converts GitHub file URLs into jsDelivr CDN links.
Built with vanilla JavaScript, no dependencies, and designed to be deployed easily on platforms like Vercel or Netlify.
Live demo:
https://cdn-api-dev.vercel.app/
Instead of using a normal GitHub file URL like:
https://github.com/user/repo/blob/main/file.js
arduino Copy code
You get a fast jsDelivr CDN link:
https://cdn.jsdelivr.net/gh/user/repo@main/file.js
yaml Copy code
This helps serve files faster and more reliably.
/api/cdn?url=GITHUB_URL
yaml Copy code
/api/cdn?url=https://github.com/user/repo/blob/main/script.js
yaml Copy code
https://cdn.jsdelivr.net/gh/user/repo@main/script.js
yaml Copy code
The response is returned as plain text (not JSON).
https://github.com/user/repo/blob/branch/file
shell Copy code
https://raw.githubusercontent.com/user/repo/branch/file
yaml Copy code
- Non-GitHub URLs
- Private repositories
- GitHub release assets
Deploy the repository and the API will be available automatically as a serverless function.
Use the same logic inside a Netlify serverless function.
MIT