How to Build a One-Time QR Code with URL Redirect

Requirement https://t.me/blacktechsharing/183161 Approach A QR code is essentially a string of characters embedded in an image. This string can be a URL. Since the QR code image has already been sent to others, and you can't go to their computer or phone to delete the image, how is a "one-time QR code" implemented? If the QR code image stays the same, then the URL A corresponding to the QR code stays the same. When you visit URL A, you're accessing a server. This server can make everyone who visits URL A redirect to a new URL B. We define URL B as the URL that actually carries the real meaning. We let the server allow only the first visitor to URL A to be redirected to URL B; subsequent visits to URL A will have the redirection disabled. This is how a "one-time QR code" is implemented.

白嫖worker 自建短链服务 Url-Shorten-Worker 支持阅后即焚snapchat mode 配合二维码生成工具 制作一次性二维码

需求 https://t.me/blacktechsharing/183161 思路 二维码实际上就是以一种图片的方式写的一串字符. 这串字符可以是一个网址. 既然这个二维码图片已经发给别人了, 你不可以跑到别人的电脑或者手机里面去删掉图片, 那么"一次性二维码"是怎么实现的呢? 二维码图片不变, 那么二维码对应的网址A不变. 你访问网址A就是访问一个服务器. 这个服务器可以让来访问网址A的人都跳转到一个新的网址B. 我们定义网址B才是真正有实际意义的网址. 让服务器只允许第一次访问网址A的人跳转到网址B, 以后再来访问网址A, 跳转都失效. 这样就实现了 "一次性二维码".

URL Shortener on Cloudflare Workers with Visit Count

Thanks to https://github.com/EasyChris/Url-Shorten-Worker for implementing the basic counting functionality. Building on this, I further optimized the operation page so that you can read the visit count directly on the operation page, without needing to check the visit count in the KV backend. Demo

白嫖worker 自建短链服务 Url-Shorten-Worker 支持访问计数 visit count 支持查询短链 API接口增删查齐全 可以作为独立短链API服务

感谢 https://github.com/EasyChris/Url-Shorten-Worker 实现基本的计数功能. 我在此基础上, 继续优化了操作页面, 可以在操作页面读出访问计数, 不需要到KV后台去看访问计数了. 效果

Fix Url-Shorten-Worker API Error: CORS Solution

Question  Wanted to debug Url-Shorten-Worker, saved index.html on local computer, called the server API at https://1way.eu.org/, got an error Access to fetch at 'https://1way.eu.org/bodongshouqulveweifengci' from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

调试 Url-Shorten-Worker API报错 from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

问题  想调试 Url-Shorten-Worker, 把 index.html 保存在本地电脑上, 调用服务器https://1way.eu.org/的API, 报错 Access to fetch at 'https://1way.eu.org/bodongshouqulveweifengci' from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.