ssr
Gitea Actions Demo / build_and_push (push) Successful in 52s Details

This commit is contained in:
artem 2026-09-19 00:19:41 +03:00
parent 1ead1ccbd4
commit 3535873c40
1 changed files with 18 additions and 5 deletions

View File

@ -112,7 +112,8 @@ ${workoutsHtml}
};
res.send(renderTemplate({ meta, content, assetTags: getAssetTagsSafe() }));
} catch {
} catch (err) {
console.error("SSR error:", err);
res.status(500).send("Internal Server Error");
}
});
@ -151,7 +152,8 @@ ${list}
};
res.send(renderTemplate({ meta, content, assetTags: getAssetTagsSafe() }));
} catch {
} catch (err) {
console.error("SSR error:", err);
res.status(500).send("Internal Server Error");
}
});
@ -160,7 +162,15 @@ ${list}
app.get("/public/workouts/:id", async (req: Request, res: Response) => {
try {
const detail = await getPublicWorkout(req.params.id);
const w = detail.workout;
const w = (detail as any).workout || detail;
if (!w || !w.name) {
console.error(
"SSR: unexpected API response shape:",
JSON.stringify(detail).slice(0, 500),
);
res.status(500).send("Unexpected API response");
return;
}
const content = `
<h1>${escapeHtml(w.name)}</h1>
@ -199,6 +209,7 @@ app.get("/public/workouts/:id", async (req: Request, res: Response) => {
res.send(renderTemplate({ meta, content, assetTags: getAssetTagsSafe() }));
} catch (err: unknown) {
console.error("SSR error:", err);
// Check for 404 from API
if (
err &&
@ -228,7 +239,8 @@ app.get("/routes", async (_req: Request, res: Response) => {
};
res.send(renderTemplate({ meta, content, assetTags: getAssetTagsSafe() }));
} catch {
} catch (err) {
console.error("SSR error:", err);
res.status(500).send("Internal Server Error");
}
});
@ -256,7 +268,8 @@ app.get("/sitemap.xml", async (_req: Request, res: Response) => {
res.set("Content-Type", "application/xml; charset=utf-8");
res.send(xml);
} catch {
} catch (err) {
console.error("SSR error:", err);
res.status(500).send("Internal Server Error");
}
});