The browser never talks to Strapi: pages call Nitro endpoints under server/api/, which are the only place Strapi queries are built. That keeps the Strapi URL internal to the Docker network and avoids CORS entirely. Article bodies are rendered from Markdown to HTML in the endpoint, so the content is server-rendered and crawlable, marked stays out of the client bundle, and the meta description is derived from the opening of the body. Pages carry canonical URLs, Open Graph tags and BlogPosting structured data, and handle empty, missing and failed states.
15 lines
486 B
TypeScript
15 lines
486 B
TypeScript
import type { StrapiImage } from '#shared/types/blog'
|
|
|
|
/**
|
|
* Strapi returns media paths relative to its own origin; the browser needs
|
|
* absolute ones. Remote providers (S3) already return absolute URLs.
|
|
*/
|
|
export function useMediaUrl() {
|
|
const { public: config } = useRuntimeConfig()
|
|
|
|
return (image: StrapiImage | null | undefined): string | null => {
|
|
if (!image?.url) return null
|
|
return image.url.startsWith('http') ? image.url : `${config.strapiUrl}${image.url}`
|
|
}
|
|
}
|