无服务器 自建短链服务 Url-Shorten-Worker 完整的部署教程

源码 GitHub: https://github.com/crazypeace/Url-Shorten-Worker

申请Cloudflare账号,略。

创建一个KV

记得这个KV的名字,以 urlsrv 为例


查看此KV

添加一个条目Entry

密钥key为password,值value为一个随机字符串.

* password这个key是在脚本中要引用的,所以要设置这个。

随机字符串可以使用http://git.io/xkcdpw生成

随机字符串以 yejiandianci 为例


创建Worker服务


设置绑定KV



变量名称必须设置为 LINKS, KV的名字选刚刚创建的 urlsrv

* LINKS 是在脚本中要引用的,所以要设置这个。换句话说,如果你使用别的脚本,可能这个变量名称就不是LINKS了。

编辑Worker的脚本


把原有的内容全部删掉


换成:https://github.com/crazypeace/Url-Shorten-Worker/blob/main/worker.js 的内容

保存并部署


======

如果要当网络记事本 PasteBin

如果要当图床 Image Hosting

如果要当网络日记本, 支持MarkDown


======

要访问 你的worker域名/yejiandianci 来打开使用页面

如:https://snowy-disk-fd82.ciys.workers.dev/yejiandianci


======

后记

你可以通过在你自己的域名下worker页面添加一个路由指向worker的方式来实现比如 https://1way.eu.org/mtSzm6 替代 snowy-disk-fd82.ciys.workers.dev/yejiandianci 的效果。


======

开发记录

直接访问域名返回404。在KV中设置一个entry,保存秘密path,只有访问这个path才显示使用页面。

https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html

支持自定义短链

https://zelikk.blogspot.com/2022/07/url-shorten-worker-custom.html

API 不公开服务

https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html

页面缓存设置过的短链

https://zelikk.blogspot.com/2022/08/url-shorten-worker-localstorage.html

长链接文本框预搜索localStorage

https://zelikk.blogspot.com/2022/08/url-shorten-worker-bootstrap-list-group-oninput.html

增加删除某条短链的按钮

https://zelikk.blogspot.com/2022/08/url-shorten-worker-delete-kv-localstorage.html

访问计数功能 可查询短链 成为功能完整的短链API系统

https://zelikk.blogspot.com/2023/11/url-shorten-worker-visit-count-api-api.html

阅后即焚功能, 可制作一次性二维码

https://zelikk.blogspot.com/2023/11/url-shorten-worker-snapchat-mode.html

增加读取 KV 中全部记录的功能

https://zelikk.blogspot.com/2024/01/url-shorten-worker-load-cloudflare-kv.html

变身网络记事本 Pastebin

https://zelikk.blogspot.com/2024/01/url-shorten-worker-pastebin.html

变身图床 Image Hosting

https://zelikk.blogspot.com/2024/01/url-shorten-worker-image-hosting-base64.html

变身日记本 NetJournal 支持Markdown

https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal.html

https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal-markdown.html


评论

The Hotest in Last 30 Days

ClouDNS .asia免费域名 托管到CloudFlare开CDN白嫖Websocket WS通道翻墙 / desec.io