Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

OneURL Backend - Link Preview Service

Express server for fetching link preview metadata with rate limiting, validation, and error handling.

Features

  • Input validation with Zod
  • Rate limiting (strict: 10/min, general: 100/15min)
  • CORS support
  • Error handling
  • Request logging
  • Fallback scraping with Cheerio
  • Production-ready error handling

Development

bun install
bun run dev

Production

bun run build
bun run start

Environment Variables

Create a .env file in the backend directory:

# Server Port
PORT=3001

# Frontend URL(s) for CORS
# Development: http://localhost:3000
# Production: https://oneurl.live
# Multiple URLs can be separated by commas
FRONTEND_URL="http://localhost:3000"

# Environment
NODE_ENV="development"

Production Setup:

PORT=3001
FRONTEND_URL="https://oneurl.live"
NODE_ENV="production"

Multiple Origins (if needed):

FRONTEND_URL="https://oneurl.live,https://www.oneurl.live"

API

GET /api/preview?url={url}

Fetches metadata for a given URL.

Rate Limits:

  • 10 requests per minute per IP
  • 100 requests per 15 minutes per IP

Response:

{
  "success": true,
  "data": {
    "title": "Page Title",
    "description": "Page description",
    "image": "https://example.com/image.jpg",
    "logo": "https://example.com/favicon.ico",
    "url": "https://example.com"
  }
}