import typing from fastapi.staticfiles import StaticFiles class SPAStaticFiles(StaticFiles): async def get_response(self, path: str, scope: typing.Any): response = await super().get_response(path, scope) # Default back to `index.html` for our SPA if response.status_code == 404: response = await super().get_response(".", scope) return response