Merge pull request #367 from pcardoso/feature/catch-all

Adding support for catch-all URLs
pull/369/head^2
Rui Carmo 2024-07-01 09:39:55 +01:00 zatwierdzone przez GitHub
commit 8320f7564f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -71,6 +71,8 @@ Also, keep in mind that using `nginx` caching with a `static` website worker wil
* `NGINX_INCLUDE_FILE`: a file in the app's dir to include in nginx config `server` section - useful for including custom `nginx` directives.
* `NGINX_ALLOW_GIT_FOLDERS`: (boolean) allow access to `.git` folders (default: false, blocked)
* `NGINX_CATCH_ALL` (string, defaults to ""): specifies a filename to serve to all requests regardless of path (useful when using client-side routing)
## Acme Settings

Wyświetl plik

@ -171,7 +171,7 @@ PIKU_INTERNAL_NGINX_STATIC_MAPPING = """
directio 8m;
aio threads;
alias $static_path;
try_files $uri $uri.html $uri/ =404;
try_files $uri $uri.html $uri/ $catch_all =404;
}
"""
@ -952,6 +952,8 @@ def spawn_app(app, deltas={}):
static_paths = ("/" if stripped[0:1] == ":" else "/:") + (stripped if stripped else ".") + "/" + ("," if static_paths else "") + static_paths
if len(static_paths):
try:
# pylint: disable=unused-variable
catch_all = env.get('NGINX_CATCH_ALL', '')
items = static_paths.split(',')
for item in items:
static_url, static_path = item.split(':')