Merge pull request #9800 from rragundez/404-non-html

WIP Return 404 for non html files
This commit is contained in:
Timothy Jaeryang Baek 2025-02-11 18:57:51 -08:00 committed by GitHub
commit a1554559c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -330,7 +330,11 @@ class SPAStaticFiles(StaticFiles):
return await super().get_response(path, scope)
except (HTTPException, StarletteHTTPException) as ex:
if ex.status_code == 404:
return await super().get_response("index.html", scope)
if path.endswith(".js"):
# Return 404 for javascript files
raise ex
else:
return await super().get_response("index.html", scope)
else:
raise ex