fix: ensure any non-existent file in the server is routed to the corresponding SPA

try_files avoids 404s, redirecting to SPA root; catch-all handles unknown paths for selfhost-web.
This commit is contained in:
jamesgeorge007
2023-10-22 22:59:53 +05:30
parent d6e4b6497f
commit 03e21e0b0c

View File

@@ -1,13 +1,26 @@
:3000 {
root * /site/selfhost-web
file_server
handle_path /admin* {
root * /site/sh-admin
# Serve the `selfhost-web` SPA by default
root * /site/selfhost-web
file_server
}
handle_path /backend* {
reverse_proxy localhost:3170
}
# Handle requests under `/admin*`
handle_path /admin* {
root * /site/sh-admin
file_server
# Ensures any non-existent file in the server is routed to the SPA
try_files {path} /
}
# Handle requests under `/backend*` path
handle_path /backend* {
reverse_proxy localhost:3170
}
# Catch-all route for unknown paths, serves `selfhost-web` SPA
handle {
root * /site/selfhost-web
file_server
try_files {path} /
}
}