Skip to content

Commit 30b3ad5

Browse files
committed
📘 doc: merge
1 parent 88046a6 commit 30b3ad5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/integrations/custom-404.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Custom 404 - ElysiaJS
3+
head:
4+
- - meta
5+
- property: 'og:title'
6+
content: Custom 404 - ElysiaJS
7+
8+
- - meta
9+
- name: 'description'
10+
content: You can define custom 404 using `onError` hook to intercept "NOT_FOUND" event and return a custom response
11+
12+
- - meta
13+
- property: 'og:description'
14+
content: You can define custom 404 using `onError` hook to intercept "NOT_FOUND" event and return a custom response
15+
---
16+
17+
# Custom 404
18+
You can define custom 404 using `onError` hook:
19+
```typescript
20+
import { Elysia } from 'elysia'
21+
22+
new Elysia()
23+
.onError(({ code, error }) => {
24+
if (code === 'NOT_FOUND')
25+
return new Response('Not Found :(', {
26+
status: 404
27+
})
28+
})
29+
.listen(8080)
30+
```

0 commit comments

Comments
 (0)