按站点配置
为工作区中的每个站点单独启用和配置公共 API。
按站点配置公共 API,精确控制向谁开放什么。在任何地方都以同样可预测的 JSON 结构获取已发布内容、站点地图和重定向——无需学习 GraphQL schema,也无需维护生成的客户端。下面每个请求都是真实的:一个基于 CMSHub 构建的博客,只用 curl 调用。
站点启用并将集合加入允许列表后,只需一个简单的 GET 即可获取其已发布记录——完全根据 Host 请求头解析,公共数据无需 API 密钥。
https://the-signal.blog/api/postscurl https://the-signal.blog/api/posts{
"siteId": "the-signal-4f2a",
"siteName": "The Signal",
"baseUrl": "https://the-signal.blog",
"collection": {
"id": "3b0d6f2a-9c41-4e8a-8f2e-1d4c9a7b6e11",
"slug": "posts",
"name": "Posts"
},
"data": [
{
"id": "a91f2e3c-7d5b-4a10-9c3e-6f8a2b1d0e44",
"locale": "en",
"translationOfId": null,
"data": {
"title": "Shipping a public content API without a GraphQL schema",
"slug": "shipping-a-public-content-api",
"excerpt": "Plain REST beats a bespoke query language when a frontend just needs JSON.",
"category": "Engineering",
"author": "Dana Osei",
"published_at": "2026-09-10"
}
},
{
"id": "d2c5b8a1-4e3f-4c9d-8b7a-2f1e6d5c4b33",
"locale": "en",
"translationOfId": null,
"data": {
"title": "What the quality gate actually checks before you publish",
"slug": "the-quality-gate-explained",
"excerpt": "Every generated page passes the same checks, whether it's post 1 or post 10,000.",
"category": "Product",
"author": "Dana Osei",
"published_at": "2026-09-04"
}
}
],
"meta": {
"locale": "en",
"pagination": { "start": 0, "limit": 20, "total": 2, "nextCursor": null }
}
}sitemap.xml 和 robots.txt 由内容 API 读取的同一份页面清单生成——没有需要同步的额外配置,也无需手动重新生成。
https://the-signal.blog/sitemap.xmlcurl https://the-signal.blog/sitemap.xml<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url><loc>https://the-signal.blog/posts/shipping-a-public-content-api</loc><lastmod>2026-09-10T14:22:00.000Z</lastmod></url>
<url><loc>https://the-signal.blog/posts/the-quality-gate-explained</loc><lastmod>2026-09-04T09:15:00.000Z</lastmod></url>
</urlset>在你明确配置站点对外开放的内容之前,公共内容 API 始终保持关闭——不存在默认开放、悄悄提供未发布内容或草稿的端点。
为工作区中的每个站点单独启用和配置公共 API。
公共 API 只提供已通过质量关卡并实际发布的内容——绝不提供草稿。
所有路由都位于带版本号的路径下,今天构建的集成在 CMSHub 演进后依然可用。