Skip to content

SPA Routing, Clean URLs & Custom Headers

Configure SPA fallback, Clean URLs, Custom 404 pages, and all 15 allowlisted security, caching, and CORS response headers on Hosted EZ Static Sites.

Updated View as Markdown

On Static Sites, open Site → Routing → Static Delivery in app.hostedez.com to control how nginx resolves URLs, serves 404 pages, and attaches custom HTTP response headers per path prefix.

Hosted EZ Static Delivery and Custom Response Headers settings panelHosted EZ Static Delivery and Custom Response Headers settings panel

URL resolution: SPA fallback & Clean URLs

Toggle SPA fallback and Clean URLs independently depending on your frontend architecture. Hosted EZ compiles your settings directly into nginx’s try_files directive:

SPA Fallback Clean URLs Resulting nginx try_files Recommended For
Off Off $uri $uri/ =404 Plain HTML sites with explicit .html links or /dir/index.html folders
Off On $uri $uri.html $uri/ =404 Astro, Next.js static export, Hugo, Eleventy (extensionless URLs + real 404s)
On Off $uri $uri/ /index.html React, Vite, Vue, Svelte SPAs using browser history routing
On On $uri $uri.html $uri/ /index.html Hybrid apps with pre-rendered .html marketing pages plus a client-side SPA fallback

Custom 404 page

Set Custom 404 page to a site-relative HTML file inside public_html, such as /404.html or /errors/404.html.

Validation rules:

  • Must start with / and end with .html or .htm.
  • Maximum length: 256 bytes.
  • Must not point to / itself, contain .. path traversal, or reference hidden dotfiles/directories.
  • Leave empty to use the default nginx 404 response.

Custom Response Headers

Define path-prefix header rules to customize caching, security policies, CORS, and crawler directives without managing server config files.

Limits & matching rules

  • Maximum rules per site: 25 unique path prefixes (for example, /, /assets, /_astro, /embed).
  • Maximum headers per rule: 10 headers.
  • Maximum header value length: 1,024 bytes (printable ASCII only; ", \, $, {`, and `} are rejected to prevent config injection; semicolons ; and single quotes ' are allowed for CSP and Cache-Control).
  • Precedence & inheritance: Rules are evaluated longest path prefix first and merged with the root / rule—a header defined on /assets overrides the same header on /, while other headers from / (such as Referrer-Policy or X-Frame-Options) continue to apply.
  • Platform-managed transport headers: Hosted EZ always attaches Strict-Transport-Security: max-age=31536000; includeSubDomains, Alt-Svc: h3=":443"; ma=86400 (on HTTPS), and X-Content-Type-Options: nosniff automatically—you do not need to add them yourself.

All 15 allowlisted response headers

Category Header Name Typical Use
Caching Cache-Control Immutable caching for hashed bundles, no-cache for HTML
Security Content-Security-Policy Restrict script, style, image, and frame origins
Security Content-Security-Policy-Report-Only Test a CSP policy before enforcing it
Security X-Frame-Options Prevent clickjacking (DENY or SAMEORIGIN)
Security Referrer-Policy Control Referer header leakage
Security Permissions-Policy Disable unused browser APIs (camera, microphone, geolocation)
Isolation Cross-Origin-Opener-Policy Enable cross-origin isolation (same-origin)
Isolation Cross-Origin-Embedder-Policy Pair with COOP for SharedArrayBuffer / WebAssembly (require-corp)
Isolation Cross-Origin-Resource-Policy Restrict cross-origin asset loading (same-origin or cross-origin)
CORS Access-Control-Allow-Origin Allow cross-origin fetches (fonts, JSON data, embeds)
CORS Access-Control-Allow-Methods Permitted HTTP methods (GET, HEAD, OPTIONS)
CORS Access-Control-Allow-Headers Permitted request headers
CORS Access-Control-Expose-Headers Response headers readable by browser JS
CORS Access-Control-Max-Age Preflight cache TTL in seconds
Crawlers X-Robots-Tag Prevent indexing of staging/internal paths (noindex, nofollow)

Copy-paste header recipes

Rule 1 — Path prefix /:

  • Cache-Control: no-cache, must-revalidate
  • X-Frame-Options: DENY
  • Referrer-Policy: strict-origin-when-cross-origin
  • Permissions-Policy: camera=(), microphone=(), geolocation=()

Rule 2 — Path prefix /assets:

  • Cache-Control: public, max-age=31536000, immutable

Rule 1 — Path prefix /:

  • Cache-Control: no-cache, must-revalidate
  • X-Frame-Options: SAMEORIGIN
  • Referrer-Policy: strict-origin-when-cross-origin

Rule 2 — Path prefix /_astro (or /_next/static for Next.js):

  • Cache-Control: public, max-age=31536000, immutable

Rule — Path prefix /fonts (or /data):

  • Access-Control-Allow-Origin: *
  • Access-Control-Allow-Methods: GET, HEAD, OPTIONS
  • Cross-Origin-Resource-Policy: cross-origin
  • Cache-Control: public, max-age=31536000, immutable

Rule — Path prefix /:

  • Content-Security-Policy: default-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline'; script-src 'self'; frame-ancestors 'none'

Verify active headers with curl

After saving your rules, verify the live response headers:

curl -sI https://docs.example.com/ | grep -iE '^(http|cache-control|x-frame-options|referrer-policy|content-security-policy)'
curl -sI https://docs.example.com/assets/index-abc123.js | grep -iE '^(http|cache-control)'
Navigation

Type to search…

↑↓ navigate↵ selectEsc close