refactor: update error handling in OG route and clean up dependencies
- Enhanced error handling in createErrorFallback to differentiate between error types and provide more specific responses. - Removed unused kose-font dependency from package.json. - Added @fontsource-variable/noto-sans-sc and @fontsource/noto-sans dependencies for improved font support in SSR. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -67,16 +67,15 @@ export const viteRenderBaseConfig = {
|
||||
},
|
||||
},
|
||||
localesJsonPlugin(),
|
||||
codeInspectorPlugin({
|
||||
bundler: "vite",
|
||||
hotKeys: ["altKey"],
|
||||
}),
|
||||
react({
|
||||
// jsxImportSource: "@welldone-software/why-did-you-render", // <-----
|
||||
}),
|
||||
circularImportRefreshPlugin(),
|
||||
|
||||
codeInspectorPlugin({
|
||||
bundler: "vite",
|
||||
hotKeys: ["altKey"],
|
||||
editor: "cursor",
|
||||
}),
|
||||
sentryVitePlugin({
|
||||
org: "follow-rg",
|
||||
project: "follow",
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"fastify": "5.6.0",
|
||||
"i18next": "25.5.2",
|
||||
"jotai": "2.14.0",
|
||||
"kose-font": "1.0.0",
|
||||
"linkedom": "0.18.11",
|
||||
"motion": "12.23.16",
|
||||
"ofetch": "1.4.1",
|
||||
|
||||
@@ -61,7 +61,15 @@ export const ogRoute = (app: FastifyInstance) => {
|
||||
})
|
||||
}
|
||||
|
||||
const createErrorFallback = (reply: FastifyReply) => (code: number) => {
|
||||
reply.code(code).send("Internal server error")
|
||||
const createErrorFallback = (reply: FastifyReply) => (code: number | Error) => {
|
||||
if (typeof code !== "number" && code instanceof Error) {
|
||||
reply.code(500).send(code.message)
|
||||
return null
|
||||
}
|
||||
let message = "Internal server error"
|
||||
if (code === 404) {
|
||||
message = "Not found"
|
||||
}
|
||||
reply.code(code).send(message)
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user