Free Redirects multiple domains/URLs using Deno Deploy

I once had to merge bunch of apps running on different subdomains into one App.

The domain was managed by Cloudflare and the first idea was to use Redirects from Cloudflare. However, I couldn’t make it work for some reason.

Deno Deploy has generous free tier and with just few lines of code I was able to manage setup redirects.

import { serve } from "https://deno.land/std@0.155.0/http/server.ts";
function handler(req: Request) {
  if (req.url.includes('/join')) {
    return Response.redirect("https://example.com/join", 301);
  }
  return Response.redirect("https://example.com/login", 301);
}

serve(handler);

You can write conditions or build a lookup table for request URL (req.url) in above code and you have different redirects based on different rules.

The amazing thing is, Deno deploy projects has a setting where you can use multiple domains for a single project.

Deno Deploy project domain setting


Add domains or subdomains and update DNS and Voila! You have a simple free app handling redirects.

Deploy Jekyll sites with Amazon S3

Jekyll is great as a static CMS. Amazon S3 is cheap to host static files. I use both to host few blogs.

S3 Website is the Plugin I use to deploy to S3. It’s a nifty plugin which does the job but with a catch. It depends on specific version of Java.

I bought a used ThinkPad (I love the old ThinkPads) and was trying to set up the machine to deploy the blogs. I installed Java and tried to run the usual s3_website push command but it needs a rather old version.

So if you are using S3_website plugin, you need the LTS openjdk-8. You can install it in Ubuntu with following command.
sudo apt install openjdk-8-jdk

Once installed, run java -version to make sure you have openjdk version 1.8.

That’s all! Happy hacking!

Learning to Code!

I have been trying for ages to get into programming. Hours have been spent on Moocs, Books and many tutorials. Many new year resolutions went unfulfilled. The result so far has been, well, not satisfying.

I guess the reason why I’ve been able to call myself a Programmer because I’ve been not able to focus and finish. Not able to focus on a language (Tried Ruby, Python, PHP and JS so far) or a framework (RoR, Sinatra, Django, Flask, Express).

All the articles are saying one should focus on JavaScript if he wants to be a Web/App Developer. I prefer backend programming more than frontend and NodeJS should be enough to start with.

I bought The Complete Node.js Developer Course and loving it so far. It’s good for beginners and anyone with basic understanding of JS/Programming can take it.

So, I will be focusing mostly on JS for 2018 and will be posting updates.

Hoping for the best!