cdn-api Documentation

A simple serverless API that converts GitHub file URLs into jsDelivr CDN links.

What it does

Converts GitHub URLs like:

https://github.com/user/repo/blob/main/file.js
      

Into a fast jsDelivr CDN link:

https://cdn.jsdelivr.net/gh/user/repo@main/file.js
      

Usage

Endpoint:

/api/cdn?url=GITHUB_URL
      

Example:

/api/cdn?url=https://github.com/user/repo/blob/main/script.js
      

Response:

https://cdn.jsdelivr.net/gh/user/repo@main/script.js
      

Supported URLs

https://github.com/user/repo/blob/branch/file
https://raw.githubusercontent.com/user/repo/branch/file
      

Not Supported

Deployment

Vercel: Deploy the repository and the API is available automatically.

Netlify: Use the same logic inside a serverless function.

License

MIT