import { renderToString } from "vue/server-renderer"; import { createSSRApp, h } from "vue"; import type { TheSectionFragment } from "#graphql-operations"; export default defineEventHandler(async (event) => { try { const section = await readBody(event); const { component, attrs } = useSection(section); // @ts-expect-error Properties from TheSectionFragment const app = createSSRApp({ render: () => h(component, attrs) }); const html = await renderToString(app); return html; } catch (error) { const message = error instanceof Error ? error.message : "Une erreur est survenue."; return `
${message}
`; } });