Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flodaniel opened this issue Apr 3, 2025 · 0 comments
Open

Comments

@flodaniel
Copy link

flodaniel commented Apr 3, 2025

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:

@flodaniel flodaniel changed the title Serving on basepath (e.g. /tan) does not correctly serve assets Serving on basepath (e.g. /hub) does not correctly serve assets Apr 3, 2025
@flodaniel flodaniel changed the title Serving on basepath (e.g. /hub) does not correctly serve assets Serving TSS on basepath (e.g. /hub) does not correctly serve assets Apr 3, 2025
flodaniel added a commit to flodaniel/tss-subdirectory-hosting-node that referenced this issue Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant