Skip to content

Serving TSS on basepath (e.g. /hub) does not correctly serve assets #3925

@flodaniel

Description

@flodaniel

Which project does this relate to?

Start

Describe the bug

A defined basepath is not respected correctly in TSS. A basepath in TSS can be set in theory by:

  • setting basepath: '/hub' in createTanStackRouter()
  • in app.config.ts setting server.preset to node (to be able to just serve it with an existing express app. "node" results in just a handler being generated by nitro)
  • in app.config.ts setting server.baseURL to /hub

However when I do that any assets that are served from the public folder do not get the basepath appended correctly.

Example 1
the favicon-16x16.png fails to load in production but it works when being run with vinxi dev:

export const Route = createRootRouteWithContext<RouterContext>()({
    head: () => {
        return {
            links: [
                {
                    rel: "icon",
                    type: "image/png",
                    sizes: "16x16",
                    href: `favicon-16x16.png`,
                },
            ],
        };
    },
    component: RootComponent,
});

Example 2
the image/default-1.webp fails to load in production but it works when being run with vinxi dev:

 <img src={`/img/default-1.webp`} />

Your Example Website or App

https://github.com/flodaniel/tss-subdirectory-hosting-node

Steps to Reproduce the Bug or Issue

  1. Use the provided repository to build a minimal TSS app with the props and serve it at the subpath with the express app (also in the repo)

Expected behavior

Setting the basepath as described should serve all assets correctly from the basepath.

Screenshots or Videos

No response

Platform

  • OS: any
  • Browser: Brave
  • Version: 1.114.30

Additional context

Previous discord discussions:

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