Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wwwroot/qq.wanuse.com/wp-includes/functions.php on line 6114

Notice: 函数 _load_textdomain_just_in_time 的调用方法不正确bravada 域的翻译加载触发过早。这通常表示插件或主题中的某些代码运行过早。翻译应在 init 操作或之后加载。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 6.7.0 版本添加的。) in /www/wwwroot/qq.wanuse.com/wp-includes/functions.php on line 6114

Notice: Undefined index: scheme in /www/wwwroot/qq.wanuse.com/wp-includes/canonical.php on line 752

Notice: Undefined index: host in /www/wwwroot/qq.wanuse.com/wp-includes/canonical.php on line 717

Notice: Undefined index: host in /www/wwwroot/qq.wanuse.com/wp-includes/canonical.php on line 728

Notice: Undefined index: host in /www/wwwroot/qq.wanuse.com/wp-includes/canonical.php on line 731

Notice: Undefined index: scheme in /www/wwwroot/qq.wanuse.com/wp-includes/canonical.php on line 752
使用cloudflare的workers加上kv的命名空间,实现缩短链接 个人主页,轻松缩短 - DDD网络科技
使用互联网记录分享(Wide Area Network use :更好地使用互联网。)
使用cloudflare的workers加上kv的命名空间,实现缩短链接 个人主页,轻松缩短

使用cloudflare的workers加上kv的命名空间,实现缩短链接 个人主页,轻松缩短

使用cloudflare的workers加上kv的命名空间,实现缩短链接 个人主页,轻松缩短

使用cloudflare的workers加上kv的命名空間,實現縮短連結 個人主頁,輕鬆縮短
This video captures the use of Cloudflare’s Workers plus KV’s namespace to shorten the link
Short link building personal homepage, easy to shorten
使用cloudflare workers和KV免费搭建 短链接服务

GitHub代码地址:https://github.com/wandduse/workers_kv_ … /tree/main
博客地址:https://3to1.xyz/2401
YouTube:https://youtu.be/DH0Hgt61Zg8
哔哩哔哩 (゜-゜)つロ 干杯~-bilibili:https://www.bilibili.com/video/BV1Ye411n77u/
———————————————————————————————————————–
下面是视频中用到的代码

代码:

const html404 = `<!DOCTYPE html>
<body>
  <h1>404 Not Found.</h1>
</body>`

async function handleRequest(request) {
  const requestURL = new URL(request.url);
  const path = requestURL.pathname.split("/")[1];
  if(!path){
    //自定义页面
    const html= await fetch("https://xytom.github.io/Url-Shorten-Worker/index.html");
    //首页跳转到指定地址
    //return Response.redirect("https://www.wanuse.com", 302);
    //加载自定义页面
    return new Response(await html.text(), { headers: { "content-type": "text/html;charset=UTF-8", }, });
  }else{
  const value = await DDD.get(path);
  if (value) { return Response.redirect(value, 302)}
  return new Response(html404, {  headers: {   "content-type": "text/html;charset=UTF-8", }, status: 404 });
  }
}

addEventListener("fetch", async event => {
  event.respondWith(handleRequest(event.request))
});

DDD网络科技

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注