-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom 404 document #38
Conversation
Signed-off-by: Thorsten Hans <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of non-blocking suggestions and clarifications.
readme.md
Outdated
@@ -60,6 +60,19 @@ files = [{ source = "test", destination = "/" }] | |||
environment = { FALLBACK_PATH = "index.html" } | |||
``` | |||
|
|||
### Using a custom 404 document | |||
|
|||
You can configure a `CUSTOM_404_PATH` environment variable that points to a file that will be served instead of returning a plain 404 Not Found response. If the `CUSTOM_404_PATH` environment variable is not set or points to a non-existing file, the default 404 Not Found response is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly worth noting that the custom 404 file has to be included as an asset. (This might not "just happen" if, say, the file server was configured to serve the /images
directory instead of the whole site.) And that the path is the mount path inside the fileserver component. (In your example, the source file would have to be test/custom-404.html
in order to get mounted as custom-404.html
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rewritten the paragraph, maybe you can check again @itowlson
Signed-off-by: Thorsten Hans <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks for your contribution, @ThorstenHans!
With this PR
spin-fileserver
can be configured to serve a custom 404 document instead of returning the default 404 Not Found response using theCUSTOM_404_PATH
environment variable.If the path specified in
CUSTOM_404_PATH
doesn't exist, the default 404 Not Found response is returned to the user.