Skip to content

ClydeDz/shorturl-cloudflare-workers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Short URL service using Cloudflare Workers

Demo app created for a Medium article to demonstrate Cloudflare Workers and Cloudflare KV storage. This app is a short URL service like bit.ly and the likes. We're also automatically deploying this Cloudflare Worker using GitHub Actions.

Creating a short URL

Once you deploy both workers to your Cloudflare account, make a POST request to https://createshorturl.<worker domain>.workers.dev/ with a application/json body like below.

{
    "uniqueKey": "git",
    "website": "https://github.com"
}

Testing the redirect

Now, if you head over to https://shorturl.<worker domain>.workers.dev/git, it will redirect you to https://github.com because the website that matches the uniquekey "git" supplied earlier and stored in the KV storage.

See the About section of this repo for the link to the Medium article.

Follow me on Medium @ClydeDz.