Decide where the pages of a Core dna site are composed before writing code: on the platform, in your own application, or on the platform with a few pieces filled in by the browser. The decision tree, each shape in depth, multi-brand and languages, and a table and case studies to make the call.
L2
Unit 02 · Headless, over the three API surfaces
What a headless build must rebuild
Headless, over the three API surfacesPage 7 of 29Updated
Routing, preview, the sitemap, redirects and 404s, SEO tags and cache invalidation: what each involves on Core dna, the API calls it rests on, and a worksheet that turns a preference for headless into an estimate.
Who this is for. The lead estimating a headless build. This page turns an architectural preference into a number: each item below is work your front end takes on, with what it involves and which calls it rests on, so that you can size it against your framework. It gives no day counts, because they depend on the framework and on how many kinds of record have URLs.
Routing
Every incoming path has to become a record, or a 404. For pages, GET /cdna-api/pages/page/{path} does the lookup and resolves custom URLs on the way (REST). Every other kind of record with a URL, posts, products, book pages, custom entity records, has a route of its own, so your router decides which kind a path belongs to before asking. Keep the home page's id in your configuration and read it by id.
Rewrites and redirects are a second part of routing. Editors enter them in the admin, and the platform applies them only to the pages it renders itself, before anything else. Your router reads them and applies them in the same order:
The site's rewrites, in the order they apply
GET /cdna-api/rewrites/rewrites?limit=3&orderBy=position&properties={id,source,target,matchType,action,redirectCode} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
matchType is exact or regex; action is redirect, sent with redirectCode, or rewrite, which serves the target's content at the source path. Cache the list in your front end and read it again when it changes.
Preview
A route in your front end that renders a draft revision, never cached, behind a URL nobody can guess, reached from the admin's live preview. The platform provides the entry point, the Alternative live preview url setting; the route is yours. Preview without a public URL describes it.
The sitemap
The platform's /sitemap.xml lists the platform's own URLs. Yours is built from the API: every published record with a URL, its path and its modified date, leaving out records whose robots setting is Don't index, but follow or Don't index and don't follow (the two the platform's generator leaves out), with language alternates taken from each page's related language versions.
Redirects and 404 handling
A path that matches no rewrite and no record is your 404 page, sent with a 404 status so that search engines drop it. Redirects come from the rewrites above. Old URLs from a previous site are usually added there in bulk at go-live, so the router must read them before the first visitor arrives.
SEO tags
Every record carries SEO settings: title, description, keywords, canonical URL, alternate URLs, robots and share image, read through the API as seoSettings{title,description,canonicalUrl,robots} and so on. The fallbacks are yours too: what to print when an editor left the title empty.
Caching and invalidation
API responses are not cached by the platform, so your front end caches them, and it needs to know when to drop them. A job on the record types you show, calling a revalidation endpoint of yours, does that (Knowing when content changed).
The worksheet
Fill in the last column against your framework before committing. The total is the real cost of going headless, and it is the part stakeholders do not see.
Item
What it involves
Rests on
Estimate
Routing
Path to record for each kind of record with a URL; the home page
The page-by-path route; each module's routes
Rewrites and redirects
Exact and regular-expression matches, redirect and rewrite actions, re-read on change
/cdna-api/rewrites/rewrites
404 and error pages
Status codes and templates for missing records and failures
A 404 from the API
Rendering layouts and components
One renderer per layout and per component layout
areasContent, or areaText(name) per area
Preview
A secret-protected, uncached route rendering a draft revision
The Alternative live preview url setting; a backend credential
Drafts kept out
retrieveUnpublished=0 on every public read, and a published check on reads by id
The published filter
SEO tags
Printing each record's settings, with fallbacks
seoSettings
Sitemap
All published records with URLs, robots respected, language alternates
The list routes
Cache and revalidation
A cache in your front end, and an endpoint a job calls
A job with entity events and an HTTP request action
Forms
Rendering each form, its validation messages and its steps
/cdna-api/forms/submission/{id}
Member pages
Sign-in, registration, password reset, the account area