Skip to content

Improve page experience using try_files-ish approach for SPA/static pages#383

Open
inFocus7 wants to merge 3 commits intoagentregistry-dev:mainfrom
inFocus7:infocus7/serve-ui-files-update
Open

Improve page experience using try_files-ish approach for SPA/static pages#383
inFocus7 wants to merge 3 commits intoagentregistry-dev:mainfrom
inFocus7:infocus7/serve-ui-files-update

Conversation

@inFocus7
Copy link
Collaborator

@inFocus7 inFocus7 commented Mar 19, 2026

Description

Motivation

A minor annoyance I hit is during development (and maybe it happens in production setups), I try to reload /deployed, but this ends up loading a next.js directory tree instead of the page. We should be serving the page itself.

Changes

  • Instead of serving the paths directly (which leads to /deployed -> display directory), we now serve static files and html (if found).
    • Using the try_files approach like in nginx, we fallback from (1) exact file matches, (2) *.html, (3) root SPA.
    • Note: For the final fallback, had to use ServeContent as dictated in the go docs, since hitting / redirects to , which i believe redirect to `/`, back to , infinitely.
    • As another special case, ServeFile redirects any request where r.URL.Path ends in "/index.html" to the same path, without the final "index.html". To avoid such redirects either modify the path or use ServeContent.

Change Type

/kind fix

Changelog

Fixes static page UI loading, allowing load of non-root paths.

Additional Notes

Validation

Simply ran make run-docker. May require browser cache clearance.

Before

static.serve.-.before.mp4

After

static.serve.-.after.mp4

…tic pages

Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
@inFocus7 inFocus7 marked this pull request as ready for review March 19, 2026 20:07
Copilot AI review requested due to automatic review settings March 19, 2026 20:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the embedded UI static file serving logic to behave more like try_files, improving reload behavior for Next.js static export routes (e.g., /deployed).

Changes:

  • Replaces the plain http.FileServer UI handler with a custom resolver: exact file → <path>.htmlindex.html.
  • Uses http.ServeContent for the index.html fallback to avoid FileServer redirect behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
@inFocus7 inFocus7 enabled auto-merge March 20, 2026 18:03
@inFocus7 inFocus7 added this pull request to the merge queue Mar 20, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 20, 2026
@inFocus7 inFocus7 added this pull request to the merge queue Mar 21, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2026
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.

3 participants