import { NextRequest } from "next/server"; // Server-side URL of the K-TV backend (never exposed to the browser). // Falls back to the public URL if the internal one isn't set. const API_URL = process.env.API_URL ?? process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:4000/api/v1"; /** * GET /api/stream/[channelId]?token= * * Resolves the backend's 307 stream redirect and returns the final * Jellyfin URL as JSON. Browsers can't read the Location header from a * redirected fetch, so this server-side route does it for them. * * Returns: * 200 { url: string } — stream URL ready to use as