Fix running in subpath again.
This commit is contained in:
parent
312e3fdf4b
commit
25b7aad606
4 changed files with 475 additions and 482 deletions
|
|
@ -128,7 +128,7 @@ class HttpAPI:
|
|||
for route in get_routes(RouteType.HTTP).values():
|
||||
routePath: str = f"/{route.path.lstrip('/')}"
|
||||
|
||||
if self.config.base_path == route.path:
|
||||
if route.path in (self.config.base_path, "/"):
|
||||
pass
|
||||
elif "" == base_path or not routePath.rstrip("/").startswith(base_path.rstrip("/")):
|
||||
route.path = f"{base_path}/{route.path.lstrip('/')}"
|
||||
|
|
@ -272,8 +272,26 @@ class HttpAPI:
|
|||
.replace('baseURL:""', f'baseURL:"{rewrite_path}/"')
|
||||
)
|
||||
|
||||
response.body = content.encode("utf-8")
|
||||
return response
|
||||
new_response = web.Response(text=content, content_type="text/html")
|
||||
|
||||
for k, v in response.headers.items():
|
||||
if k.lower() != "content-type":
|
||||
new_response.headers[k] = v
|
||||
|
||||
for morsel in response.cookies.values():
|
||||
new_response.set_cookie(
|
||||
morsel.key,
|
||||
morsel.value,
|
||||
expires=morsel["expires"],
|
||||
domain=morsel["domain"],
|
||||
max_age=morsel["max-age"],
|
||||
path=morsel["path"],
|
||||
secure=bool(morsel["secure"]),
|
||||
httponly=bool(morsel["httponly"]),
|
||||
samesite=morsel["samesite"] or None,
|
||||
)
|
||||
|
||||
return new_response
|
||||
|
||||
if request.path.startswith(static_path) and isinstance(response, web.FileResponse):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -124,8 +124,15 @@ def preload_static(root_path: Path, config: Config) -> None:
|
|||
STATIC_FILES[config.base_path] = STATIC_FILES["/index.html"]
|
||||
add_route(method="GET", path=config.base_path, handler=serve_static_file, name="index")
|
||||
|
||||
if "/" != config.base_path:
|
||||
|
||||
async def redirect_index(config: Config) -> web.Response:
|
||||
return web.Response(status=web.HTTPFound.status_code, headers={"Location": config.base_path})
|
||||
|
||||
add_route(method="GET", path="/", handler=redirect_index, name="index_redirect")
|
||||
|
||||
if preloaded < 1:
|
||||
message = f"Failed to find any static files in '{static_dir}'."
|
||||
message: str = f"Failed to find any static files in '{static_dir}'."
|
||||
if config.ignore_ui:
|
||||
LOG.warning(message)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
"web-types": "./web-types.json",
|
||||
"dependencies": {
|
||||
"@pinia/nuxt": "^0.11.1",
|
||||
"@sentry/nuxt": "^9.30.0",
|
||||
"@sentry/nuxt": "^9.33.0",
|
||||
"@vueuse/core": "^13.4.0",
|
||||
"@vueuse/nuxt": "^13.4.0",
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue