feat: n8n can replace the JSON-LD of content elements via PUT /api/json-ld/{uid}
n8n is the source of truth for the SEO markup: the element's bodytext is overwritten with the posted object, wrapped in a ld+json script element. Values are escaped with JSON_HEX_TAG so they cannot close the element. The endpoint has its own key (jsonLdApiKey, header only) and writes through DataHandler as the non-admin backend user _n8n, so every change is in the record history and can be undone there, and the page cache is cleared. Until the key and the user exist on prod, every request answers 403/503. Prod setup (group n8n, user _n8n) is in docs/cms-api.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
81a8013e8a
commit
7ae9aa266e
6 files changed
+185
-11
No files matched your search
+27
-3
@@ -1,7 +1,7 @@
|
||||
# CMS API
|
||||
|
||||
Endpoints TYPO3 serves to other systems: **MyE&P** (hotel and product content, calendar hotels)
|
||||
and the **chatbot** (content feed). They are answered by `EP\EpProducts\Middleware\ApiMiddleware`
|
||||
Endpoints TYPO3 serves to other systems: **MyE&P** (hotel and product content, calendar hotels),
|
||||
the **chatbot** (content feed) and **n8n** (JSON-LD of content elements). They are answered by `EP\EpProducts\Middleware\ApiMiddleware`
|
||||
before the page resolver, so they do not depend on a page and are never page-cached.
|
||||
|
||||
The other side of these contracts is documented in MyE&P's `docs/api-consumer-guide.md`
|
||||
@@ -9,7 +9,7 @@ The other side of these contracts is documented in MyE&P's `docs/api-consumer-gu
|
||||
|
||||
## Authentication
|
||||
|
||||
All endpoints need the shared key `cmsApiKey` from the `ep_products` extension configuration
|
||||
All endpoints except `/api/json-ld/` (see there) need the shared key `cmsApiKey` from the `ep_products` extension configuration
|
||||
(Settings → Extension Configuration → ep_products, tab ContentFeed):
|
||||
|
||||
- header `X-Api-Key: <key>` (preferred, query strings end up in access logs), or
|
||||
@@ -99,3 +99,27 @@ The content feed for the chatbot (`EP\EpProducts\ContentFeed\ContentFeedApi`).
|
||||
Configuration (extension configuration `ep_products`, tab ContentFeed): `contentFeedEnabled`,
|
||||
`contentFeedSites`, `contentFeedLanguages`, `contentFeedExcludedPages`,
|
||||
`contentFeedNewsDetailPages`.
|
||||
|
||||
## `PUT /api/json-ld/<uid>`
|
||||
|
||||
n8n writes the JSON-LD (SEO markup) of a content element (`EP\EpProducts\JsonLd\JsonLdApi`).
|
||||
n8n is the source of truth: the element's `bodytext` is replaced with the posted object wrapped in
|
||||
`<script type="application/ld+json">`, whatever the element held before. Other fields (CType,
|
||||
hidden, …) are left alone; each translation is its own uid.
|
||||
|
||||
- Key: `jsonLdApiKey` (extension configuration `ep_products`, tab JsonLd), only as header
|
||||
`X-Api-Key`; `?key=` is not accepted.
|
||||
- `POST` does the same as `PUT` (n8n's default method).
|
||||
- Body: the JSON-LD object (or array of objects) itself, e.g.
|
||||
`{"@context": "https://schema.org", "@type": "Event", …}`. Pretty-printed when stored;
|
||||
`<` and `>` are escaped as `\u003C`/`\u003E`, so a value cannot close the script element.
|
||||
- `200 {"uid": 13169, "pid": 24, "changed": true}`; `changed: false` when the stored markup is
|
||||
already identical (nothing written).
|
||||
- `400` for invalid JSON or a scalar, `403` for a wrong or missing key, `404` for an unknown or
|
||||
deleted uid, `405` for other methods, `503` when the backend user `_n8n` is missing, `500` with
|
||||
`errors` when DataHandler refuses the write.
|
||||
|
||||
The write goes through DataHandler as the backend user `_n8n` (no password, so no login; group
|
||||
`n8n` with *Tables (modify)* `tt_content` and *Explicitly allow* `tt_content:CType:html`; page
|
||||
permissions are bypassed). Every change is in the element's history, where it can be undone, and
|
||||
clears the page cache.
|
||||
Reference in new issue
Block a user