Skip to content

iot-bin/random-redirect-link

Repository files navigation

This is a Next.js project bootstrapped with create-next-app.

Configuration

Create a .env.local file in the root directory with the following variables:

# Console Authentication
CONSOLE_PASSWORD=your-console-password

# Branding Configuration
SITE_TITLE=Microbin Console
SITE_DESCRIPTION=Microbin short link console
SITE_SUBTITLE=创建自定义路径短链接(跳转)

# API Targets Configuration (JSON format)
# Define multiple API environments with their credentials and redirect domains
API_TARGETS=[{"id":"prod","name":"Production (link.microbin.dev)","apiBaseUrl":"https://api.link.microbin.dev","adminToken":"your-prod-admin-token","redirectBaseUrl":"https://link.microbin.dev"},{"id":"staging","name":"Staging (link-staging.microbin.dev)","apiBaseUrl":"https://api-staging.link.microbin.dev","adminToken":"your-staging-admin-token","redirectBaseUrl":"https://link-staging.microbin.dev"}]

# Default target ID (optional, defaults to first target in API_TARGETS)
DEFAULT_TARGET_ID=prod

Required Variables

  • CONSOLE_PASSWORD: The password required to access the console
  • API_TARGETS: JSON array of API target configurations (see below)

API Targets Configuration

The API_TARGETS variable defines multiple API environments that can be selected in the console. Each target must have:

  • id: Unique identifier for the target (e.g., "prod", "staging")
  • name: Display name shown in the UI (e.g., "Production (link.microbin.dev)")
  • apiBaseUrl: The backend Admin API URL (e.g., "https://api.link.microbin.dev")
  • adminToken: Secret admin token for the API (kept server-side only)
  • redirectBaseUrl: The public short link domain (e.g., "https://link.microbin.dev")

Example with multiple environments:

[
  {
    "id": "prod",
    "name": "Production (link.microbin.dev)",
    "apiBaseUrl": "https://api.link.microbin.dev",
    "adminToken": "your-prod-admin-token",
    "redirectBaseUrl": "https://link.microbin.dev"
  },
  {
    "id": "staging",
    "name": "Staging (link-staging.microbin.dev)",
    "apiBaseUrl": "https://api-staging.link.microbin.dev",
    "adminToken": "your-staging-admin-token",
    "redirectBaseUrl": "https://link-staging.microbin.dev"
  }
]

Optional Branding Variables

  • SITE_TITLE: Browser tab title and main heading (default: Microbin Console)
  • SITE_DESCRIPTION: Page meta description (default: Microbin short link console)
  • SITE_SUBTITLE: Page subtitle (default: 创建自定义路径短链接(跳转))
  • DEFAULT_TARGET_ID: Default selected API target (defaults to first target)

Security Note: The adminToken values are kept server-side only and never exposed to the browser. Only the redirectBaseUrl is sent to the frontend for displaying the short link domain.

Deployment on Vercel or other platforms: Set these environment variables in your platform's dashboard (e.g., Vercel Project Settings → Environment Variables). All sensitive credentials remain server-side.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You will be redirected to the login page. Enter the password you configured in CONSOLE_PASSWORD to access the console.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •