Skip to content

Instantly share code, notes, and snippets.

View kmonsoor's full-sized avatar
:octocat:

Khaled Monsoor kmonsoor

:octocat:
View GitHub Profile
@kmonsoor
kmonsoor / url-forwarder-worker-cloudflare.js
Created May 25, 2021 03:38
Core worker code for url-forwarder based on Cloudflare Worker-KV
// This is the companion code for the linked blog
// https://blog.kmonsoor.com/on-edge-shortlink-server-cloudflare-kv-worker
// Please check the blog to get the context
// author : Khaled Monsoor (@kmonsoor)
// last updated: 25-May-2021
const failsafeURL = "https://kmonsoor.com" // replace it with yours ;)
const defaultStatusCode = 301 // standard HTTP code for redirection, don't change
addEventListener("fetch", (event) => {