Custom 404 for static file server #331
-
I am following the "static-file-server" example but do not understand how can I customize 404 error response. For example, I would want to return a custom HTML page. From the ServeDir source code below, it does not look like you can customize ServeDir itself:
So, I am trying to intercept the response somehow. My current attempt is to use custom service with layer but could not make it to work:
In this example, nothing would call NotFound's Is there any other option I could use? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you want a customize 404 response that only applies to |
Beta Was this translation helpful? Give feedback.
If you want a customize 404 response that only applies to
ServerDir
then you have to route to a service that internally callsServeDir
and changes the response as necessary. There is an example of doing that here #87 (comment)