Find a file
2024-03-07 18:41:31 +02:00
.gitea/workflows ci: add action 2024-03-07 18:39:15 +02:00
src ci: add action 2024-03-07 18:39:15 +02:00
.dockerignore ci: add action 2024-03-07 18:39:15 +02:00
.editorConfig initial import 2023-07-07 08:15:37 +02:00
.gitignore initial import 2023-07-07 08:15:37 +02:00
.yarnrc.yml initial import 2023-07-07 08:15:37 +02:00
docker-compose.yml initial import 2023-07-07 08:15:37 +02:00
Dockerfile initial import 2023-07-07 08:15:37 +02:00
package.json initial import 2023-07-07 08:15:37 +02:00
README.md update readme 2024-03-07 18:41:31 +02:00
yarn.lock initial import 2023-07-07 08:15:37 +02:00

Redirector

Simple redirection service. Runs on Node and uses Hono.

Can be adapted to run on Bun, Cloudflare Workers, or any other serverless platform.

Available as a Docker image. Repository: nzambello/redirector.

Usage

yarn install
REDIRECT_URL=https://nzambello.dev PERMANENT=true PRESERVE_PATH=false yarn start

Then, open http://localhost:8787/ in your browser.

open http://localhost:8787

and you will be redirected to REDIRECT_URL from your env.

Configuration

It loads configuration from environment variables:

  • REDIRECT_URL: (required) the url to redirect to
  • PERMANENT: if true, it will return a 301 status code, otherwise 302
  • PRESERVE_PATH: if true, it will preserve the path of the original request

Docker example

docker run -p 8787:8787 -e REDIRECT_URL=https://nzambello.dev -e PERMANENT=true PRESERVE_PATH=false nzambello/redirector:latest

Docker compose example

version: "3.8"

services:
  redirector:
    image: nzambello/redirector:latest
    environment:
      - REDIRECT_URL=https://nzambello.dev
      - PERMANENT=true
      - PRESERVE_PATH=false
    ports:
      - 8787:8787

Development

To update the Docker image:

docker buildx build --platform linux/amd64,linux/arm64 -t nzambello/redirector:latest --push .