File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments