Headless CMS Integration Guide
Plan B: PHP bridge + Next.js static export for codescreen.in — end-to-end wiring explained.
Why a bridge instead of direct browser calls
The marketing site is a static export. API tokens must never ship to the browser. A server-side proxy adds the X-Website-Token header and enforces read-only GET routes.
Request flow
Browser fetches /cms-api.php?path=blog/posts on codescreen.in
PHP reads cms-api.config.php and forwards to cms.codescreen.in/api/v1
Laravel validates token, website scope, and published status
JSON flows back unchanged to the React blog pages
Local development
cs-cms on (or https://cms.codescreen.in in production)
Local Next.js dev calls the API directly with cms-api.config.php
Production codescreen.in uses cms-api.php so the token never ships in JavaScript
Whitelisted domains apply when the browser calls the CMS API directly. The production PHP bridge calls the CMS server-side and does not rely on Origin allowlists.
Security checklist: rotate tokens in Filament, keep cms-api.config.php out of git, and deploy BlogPostController scoping before production traffic.