URL shortener created using Cloudflare Worker | Supports custom homepage | Supports Menu Short | Supports short URLs, text, web page sharing, ephemeral content, expiration time, and UI adaptive interface.
Since the free plan of Cloudflare has limitations, a preview URL is not provided. Please visit Cloudflare Work for deployment.
Normally, the free plan is sufficient for personal use, but you can upgrade to a paid plan if you have high demand.
Each request uses a maximum of 10 milliseconds of CPU time. The minimum latency after the first request. Up to 100,000 requests per day (UTC+0).
Globally low-latency key-value edge storage. Up to 100,000 read operations per day. Up to 1,000 write, delete, and list operations per day.
![Preview Image](https://private-user-images.githubusercontent.com/11790369/241161397-1275583f-ae22-4ee9-a0dd-fabe40de9c63.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQyNzg2MTgsIm5iZiI6MTcyNDI3ODMxOCwicGF0aCI6Ii8xMTc5MDM2OS8yNDExNjEzOTctMTI3NTU4M2YtYWUyMi00ZWU5LWEwZGQtZmFiZTQwZGU5YzYzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIxVDIyMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJlMjVmYjNlMzEzMTZiOTdkZDdkMDE3MTIyMTk0Y2ZjZDEwYzMwZDQ4NWEwNWMxMGJiYjNmNDdiMGFjYTA1NTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QhgwwlYtiLXM52ykb2oQ42QIZx6aSsDFG6Glg26hkNM)
// Admin page path (default is "/", can be set to another path like "/admin" if hiding the homepage)
const ADMIN_PATH = "/";
// API path
const API_PATH = "/api";
// Long URL key name
const URL_KEY = "longUrl";
// Short URL key name
const URL_NAME = "shortCode";
// Short URL key name (used for API response)
const SHORT_URL_KEY = "shorturl";
// Static homepage source code link (set to replace the homepage, can be commented out if not needed)
const STATICHTML = "https://github.com/Aiayw/CloudflareWorkerKV-UrlShort/blob/8eb8866c8acfd4ed130dc94f4a2798a78c898ecb/404.html";
Response Example
{
"shortCode":"dfcw",
"type":"link",
"shorturl":"https://url.com/dfcw"
}
const statichtml = "https://github.com/Aiayw/CloudflareWorkerKV-UrlShort/blob/8eb8866c8acfd4ed130dc94f4a2798a78c898ecb/404.html"
Modify the above URL to the source code of your preferred web page. Only a single HTML file is supported. It is recommended to integrate CSS, JS, and scripts into the HTML file.
Copy the code from index.js in this project and save and deploy it in Cloudflare Worker
![Save and Deploy](https://private-user-images.githubusercontent.com/11790369/241168380-8b5e8519-32ae-4504-87a8-18945f9f08e1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQyNzg2MTgsIm5iZiI6MTcyNDI3ODMxOCwicGF0aCI6Ii8xMTc5MDM2OS8yNDExNjgzODAtOGI1ZTg1MTktMzJhZS00NTA0LTg3YTgtMTg5NDVmOWYwOGUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIxVDIyMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdhNmVlNzdmOGVlYThiNTYxMmNiMzhkYWJiMmMwYzZmZWVjZmQ4ZjgzN2IzNTE2YWQ4OTZmMjQ4YmM0NWRhMGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zNOTQsUUh96QLONdMS16_jV-RrUmFjU7O03i-inLpwU)
Thanks to Cloudflare for providing the platform and services.
使用Cloudflare Worker创建的URL缩短器|支持自定义首页|支持Menu Short|支持短网址、文本、网页分享、阅后即焚、过期时间、以及界面UI自适应。
因为Cloudflare的免费套餐有限制,所以不提供预览地址,请自行前往cloudflare Work部署。
正常来说免费套餐私人使用是完全够的,如有大量需求可付费升级套餐。
每个请求最多占用 10 毫秒 CPU 时间
第一个请求后的延迟最低
每天最多 100,000 个请求 (UTC+0)
全局性的低延迟键值边缘存储
每天最多 100,000 次读取操作
每天最多 1,000 次写入、删除和列出操作
![预览图](https://private-user-images.githubusercontent.com/11790369/241161397-1275583f-ae22-4ee9-a0dd-fabe40de9c63.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQyNzg2MTgsIm5iZiI6MTcyNDI3ODMxOCwicGF0aCI6Ii8xMTc5MDM2OS8yNDExNjEzOTctMTI3NTU4M2YtYWUyMi00ZWU5LWEwZGQtZmFiZTQwZGU5YzYzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIxVDIyMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJlMjVmYjNlMzEzMTZiOTdkZDdkMDE3MTIyMTk0Y2ZjZDEwYzMwZDQ4NWEwNWMxMGJiYjNmNDdiMGFjYTA1NTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QhgwwlYtiLXM52ykb2oQ42QIZx6aSsDFG6Glg26hkNM)
// 管理员页面路径 (默认为 / 如果隐藏首页可设置为其他路径,例如:/admin )
const ADMIN_PATH = "/";
// API 路径
const API_PATH = "/api";
// 长链接键名
const URL_KEY = "longUrl";
// 短链接键名
const URL_NAME = "shortCode";
// 短链接键名(用于 API 返回)
const SHORT_URL_KEY = "shorturl";
// 静态首页源码链接 (设置首页替换页面,不需要也可以直接注释掉)
const STATICHTML = "https://github.com/Aiayw/CloudflareWorkerKV-UrlShort/blob/8eb8866c8acfd4ed130dc94f4a2798a78c898ecb/404.html";
响应参考
{
"shortCode":"dfcw",
"type":"link",
"shorturl":"https://url.com/dfcw"
}
const statichtml = "https://github.com/Aiayw/CloudflareWorkerKV-UrlShort/blob/8eb8866c8acfd4ed130dc94f4a2798a78c898ecb/404.html"
修改上方网址为自己喜欢的网页源码,只支持单html,建议css和js和script集成进html里
复制本项目中的index.js的代码到Cloudflare Worker 点击保存并部署
![点击保存并部署](https://private-user-images.githubusercontent.com/11790369/241168380-8b5e8519-32ae-4504-87a8-18945f9f08e1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQyNzg2MTgsIm5iZiI6MTcyNDI3ODMxOCwicGF0aCI6Ii8xMTc5MDM2OS8yNDExNjgzODAtOGI1ZTg1MTktMzJhZS00NTA0LTg3YTgtMTg5NDVmOWYwOGUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIxVDIyMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdhNmVlNzdmOGVlYThiNTYxMmNiMzhkYWJiMmMwYzZmZWVjZmQ4ZjgzN2IzNTE2YWQ4OTZmMjQ4YmM0NWRhMGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zNOTQsUUh96QLONdMS16_jV-RrUmFjU7O03i-inLpwU)
感谢Cloudflare提供平台和服务。