A lightweight Nitro.js application that redirects all incoming requests to a specified target URL. Built with Nitro.
- Simple HTTP/HTTPS redirection service
- Configurable redirect status code (301, 302, etc.)
- Preserves original request paths
- Available as a Docker image
docker run -d \
-e REDIRECT_TARGET=example.com \
-e REDIRECT_STATUS_CODE=301 \
-p 3000:3000 \
piscis/nitro-web-redirect:latest# Clone the repository
git clone https://github.com/piscis/nitro-web-redirect.git
cd nitro-web-redirect
# Install dependencies (using pnpm, the recommended package manager)
pnpm install
# Configure environment variables
echo 'REDIRECT_TARGET=example.com' > .env
# Start the server
pnpm run devConfigure the application using environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
REDIRECT_TARGET |
Yes | - | Target URL for redirection (with or without protocol) |
REDIRECT_STATUS_CODE |
No | 301 | HTTP status code for redirection (301, 302, etc.) |
# Redirect to example.com with the same protocol as the request
REDIRECT_TARGET='example.com'
# Redirect to example.com with HTTPS protocol regardless of request protocol
REDIRECT_TARGET='https://example.com'
# Use a temporary redirect (302) instead of permanent (301)
REDIRECT_STATUS_CODE=302The official Docker image is available on Docker Hub:
docker pull piscis/nitro-web-redirect:latestdocker run -d \
-e REDIRECT_TARGET=example.com \
-e REDIRECT_STATUS_CODE=301 \
-p 3000:3000 \
piscis/nitro-web-redirect:latest# Build the image
docker build -t nitro-web-redirect .
# Run the container
docker run -d \
-e REDIRECT_TARGET=example.com \
-p 3000:3000 \
nitro-web-redirectversion: '3'
services:
redirect:
image: piscis/nitro-web-redirect:latest
environment:
REDIRECT_TARGET: example.com
REDIRECT_STATUS_CODE: 301
ports:
- '3000:3000'
restart: unless-stopped- Node.js v22.15.0 (or compatible version)
- pnpm v10.11.1 (recommended)
# Install dependencies
pnpm install
# Start development server
pnpm run devThe development server will be available at http://localhost:3000
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run preview- Preview production build locallypnpm run lint- Run lintingpnpm run test- Run tests
pnpm run buildpnpm startFor more deployment options, see the Nitro deployment documentation.
Run the test suite:
pnpm run test