Files
news-platform/docs/domains.md
T
David SantosandPaperclip 7b7830263b docs: architecture document and project scaffold for news-platform
- docs/architecture.md: full architecture with Astro 5 SSR vs Next.js/Nuxt
  justification, component diagram, data flow, multi-domain routing, SEO
  strategy, performance targets, and caching strategy
- docs/frontend.md, bridge.md, domains.md, seo.md, deployment.md: stubs
  with implementation detail for each layer
- config/domains/newsproject.bitreport.pt.json: first domain config
- project skeleton: frontend/, bridge/, wordpress/, config/, deploy/

Covers BIT-348 deliverables. Push pending Gitea repo creation.

Co-Authored-By: Paperclip <[email protected]>
2026-03-23 14:11:39 +00:00

2.8 KiB

Multi-Domain Configuration

Status: Stub — implementation in progress (BIT-345)


Overview

The platform supports multiple domains without code changes. Each domain has a JSON config file in config/domains/. The Astro frontend reads the config at request time based on the host header; the bridge routes to the correct WordPress endpoint using the same config.


Adding a New Domain

  1. Create config/domains/<hostname>.json (see schema below)
  2. Configure DNS to point the domain at the server
  3. If WordPress is a new instance, deploy it and update wp_endpoint
  4. No code change. No redeploy. (In SSR mode, Astro reads configs from disk per request.)

Config Schema

{
  // Identity
  "site_name": "Sports News",
  "site_description": "The best sports coverage in Portugal",

  // Visual
  "theme": "sports",                       // maps to src/themes/<theme>/
  "logo": "/assets/newsproject/logo.svg",
  "favicon": "/assets/newsproject/favicon.ico",
  "primary_color": "#e63946",

  // Navigation
  "categories": ["Football", "Basket", "F1", "Tennis", "Rugby"],
  "nav_categories": ["Football", "Basket", "F1"],

  // Backend endpoints
  "wp_endpoint": "http://wp.newsproject.local/wp-json",
  "bridge_endpoint": "http://bridge:3200",

  // Locale
  "locale": "pt_PT",
  "timezone": "Europe/Lisbon",

  // Social
  "social": {
    "twitter": "@handle",
    "facebook": "page-name"
  },

  // Features (future)
  "ads": { "enabled": false, "provider": null },
  "analytics": { "ga4": null }
}

Current Domains

Domain Config file WordPress
newsproject.bitreport.pt newsproject.bitreport.pt.json http://wp.newsproject.local

Domain Resolution in Astro

// src/lib/domain.ts
import { readFileSync, existsSync } from "node:fs";
import path from "node:path";

export function loadDomainConfig(host: string): DomainConfig {
  const hostname = host.replace(/:\d+$/, "");
  const configPath = path.join(process.cwd(), "config/domains", `${hostname}.json`);

  if (!existsSync(configPath)) {
    throw new Error(`Domain config not found: ${hostname}`);
  }

  return JSON.parse(readFileSync(configPath, "utf-8")) as DomainConfig;
}

Usage in an Astro page:

---
// src/pages/index.astro
import { loadDomainConfig } from "../lib/domain";

const host = Astro.request.headers.get("host") ?? "localhost";
const config = loadDomainConfig(host);
---
<html lang={config.locale}>
  <head><title>{config.site_name}</title></head>
  ...
</html>

Notes

  • Domain config files are not secrets — they contain only public-facing site settings
  • WordPress endpoints in wp_endpoint are internal network addresses; they must not be exposed publicly
  • Theme names map to a directory under frontend/src/themes/; if a theme is missing, the default theme is used