A simple URL shortener built for personal needs. Feed it with a URL that will respond with a slug that you can use instead.
Input | Output |
---|---|
https://dvl.sh | https://ify.lol/0KY |
Not a factual representation of the output, but simplified for clarity.
I have a CNAME of https://r.dvl.sh, which maps to https://ify.lol for convenience, as I'm using this shortener internally within my website: https://dvl.sh.
If you want to use this URL shortener for your personal needs, you won't be able to use it through https://ify.lol as it will require an Access-Token
. It is a security precaution, as I want the database to contain only the links I use in my blog posts.
Besides, whenever I make a breaking change, I do not want your links to disappear from the database.
Feel free to clone or fork this repo, make desired changes (if any) and deploy it yourself wherever you want.
With just two endpoints, you can do the necessary task.
- GET
/api/[slug]
- to retrieveJSON
data of a record by the identifier (slug) - POST
/api
- to store an URL and retrieveJSON
for that record
POST request will expect you to pass a link
as data and an Access-Token
header that will match the ACCESS_TOKEN
environment variable.
The middleware handles the redirect if the database finds the given slug; otherwise, it will remain with 404
status.
/[slug]
Personally deployed on ▲ Vercel and database on PlanetScale.
There are a few environment variables that you need to fill in, and everything will work as expected. Refer to .env.example
.