Skip to content

Fallback for SPA should support files other than index.html #855

Description

@nktnet1

Description

Currently, there is the following option (mentioned in #664):

-s, --single                        Rewrite all not-found requests to `index.html`

However, this option is limited and does not support loading custom HTML as mentioned by @woss in:

Why

Frameworks like Tanstack Start generates _shell.html by default for SPA, rather than index.html:

Alternatives

A workaround can be seen here:

Where serve.json is created with a rewrite:

{
  "rewrites": [
    {
      "source": "!/api/**",
      "destination": "/_shell.html"
    }
  ]
}

This isn't ideal, however, since the rewrite works on all paths rather than serving as a fallback, which masks the API route - thus, it needs to be excluded in the source glob. There may also be other exclusions needed apart from /api.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions