mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3
This commit is contained in:
parent
f4959eebf8
commit
b139712a91
166 changed files with 19790 additions and 5539 deletions
22
server/error-handler.ts
Normal file
22
server/error-handler.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import defaultNitroErrorHandler, {
|
||||
defineNitroErrorHandler,
|
||||
} from "nitropack/runtime/error";
|
||||
import { setResponseStatus } from "h3";
|
||||
|
||||
/**
|
||||
* Keep the legacy API error contract (`{ error: string }` JSON) for the
|
||||
* machine-facing endpoints; everything else (pages) uses the default handler.
|
||||
*/
|
||||
export default defineNitroErrorHandler((error, event) => {
|
||||
const path = event.path ?? "";
|
||||
if (
|
||||
path.startsWith("/admin/api/") ||
|
||||
path.startsWith("/api/") ||
|
||||
path.startsWith("/auth/") ||
|
||||
path.startsWith("/webhook")
|
||||
) {
|
||||
setResponseStatus(event, error.statusCode || 500);
|
||||
return { error: error.statusMessage || error.message || "Internal Server Error" };
|
||||
}
|
||||
return defaultNitroErrorHandler(error, event);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue