NODEJS Contents

CORS Basics (and Why It’s Not “A Backend Bug”)

CORS controls browser cross-origin access. Misconfiguration can expose internal APIs unintentionally.

On this page

Understanding CORS

CORS is enforced by browsers, not servers. Servers must explicitly allow origins via headers.

res.setHeader('Access-Control-Allow-Origin', 'https://example.com');

Production Risk

Using wildcard origins on authenticated endpoints exposes credentials. Always restrict origins intentionally.