Skip to content

Comments

Fix SPA routing for production builds - serve index.html on 404#58

Closed
Copilot wants to merge 4 commits intofeature/multiuserfrom
copilot/fix-not-found-errors-multiuser
Closed

Fix SPA routing for production builds - serve index.html on 404#58
Copilot wants to merge 4 commits intofeature/multiuserfrom
copilot/fix-not-found-errors-multiuser

Conversation

Copy link

Copilot AI commented Feb 18, 2026

Summary

Production builds (pnpm build) returned 404 for client-side routes like /login, while dev mode worked correctly. Starlette's StaticFiles with html=True doesn't properly fallback to index.html for all SPA routes.

Solution: Override get_response in NoCacheStaticFiles to catch 404 exceptions and serve index.html when html=True:

async def get_response(self, path: str, scope: Scope) -> Response:
    try:
        return await super().get_response(path, scope)
    except HTTPException as exc:
        if exc.status_code == 404 and self.html:
            return await super().get_response("index.html", scope)
        raise

This ensures all unmatched routes serve the SPA entry point, allowing client-side routing to handle navigation.

Related Issues / Discussions

N/A

QA Instructions

  1. Build frontend: cd invokeai/frontend/web && pnpm build
  2. Start backend with production build
  3. Navigate directly to /login or any client-side route via URL
  4. Verify SPA loads instead of returning "Not found"
  5. Verify existing static assets (JS, CSS, images) still load normally

Merge Plan

N/A

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable) - No existing test infrastructure for static file serving
  • ❗Changes to a redux slice have a corresponding migration - N/A
  • Documentation added / updated (if applicable) - N/A
  • Updated What's New copy (if doing a release after this PR)
Original prompt

This section details on the original issue you should resolve

<issue_title>[bug]: "Not found" errors in multiuser mode</issue_title>
<issue_description>### Is there an existing issue for this problem?

  • I have searched the existing issues

Install method

Invoke's Launcher

Operating system

Linux

GPU vendor

Nvidia (CUDA)

GPU model

No response

GPU VRAM

No response

Version number

feature/multiuser branch

Browser

No response

System Information

No response

What happened

**IMPORTANT: working in the branch feature/multiuser.

When launching invoke with the frontend using pnpm dev, the application functions as expected. On the first launch, it asks the administrator to set up an account and then redirects to /login to obtain the login credentials.

However, when launching invoke with the frontend built using pnpm build, after collecting the administrator account information, it redirects to /login and the application returns a white page with the text "Not found."

What you expected to happen

I expect pnpm dev and pnpm build to produce functionally identical user experiences.

How to reproduce the problem

No response

Additional context

No response

Discord username

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 18, 2026 22:49
…iles

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
…e.types

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 'Not found' errors in multiuser mode Fix SPA routing for production builds - serve index.html on 404 Feb 18, 2026
Copilot AI requested a review from lstein February 18, 2026 22:53
@lstein lstein changed the base branch from main to feature/multiuser February 18, 2026 22:58
@lstein lstein closed this Feb 20, 2026
@lstein lstein deleted the copilot/fix-not-found-errors-multiuser branch February 20, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: "Not found" errors in multiuser mode

2 participants