Skip to content
Source
Sign inSign up
TanStack/router

throw redirect in beforeLoad with rewriteBasePath ignores the rewrite #5300

Send to my agent
Closedomridevk(GitHub profile, opens in a new tab) opened this issue 2 comments

Which project does this relate to?

Router

Describe the bug

it cannot easily be reproduced in stackblitz, however, I forked and create a repo in the examples: https://github.com/TanStack/router/commit/5d32b97b0b6a4ab8cb3b0a7d4f98376722be371f to reproduce:

  1. Run basic-ssr-streaming-file-based
  2. Go to http://localhost:3000/my-app/posts/2
  3. Notice it is being redirected to http://localhost:3000/error

This only happens when the beforeLoad happens on the server, if you set the SSR to false on the component that throws the redirect, the issue doesn't happen.

Expected: it should redirect to http://localhost:3000/my-app/error

I will try to create a PR, not sure I will have the capacity this week, Thanks for the quick response!!

Your Example Website or App

https://github.com/TanStack/router/commit/5d32b97b0b6a4ab8cb3b0a7d4f98376722be371f

Steps to Reproduce the Bug or Issue

  1. Run basic-ssr-streaming-file-based
  2. Go to http://localhost:3000/my-app/posts/2
  3. Notice it is being redirected to http://localhost:3000/error

Expected behavior

Expected: it should redirect to http://localhost:3000/my-app/error

Screenshots or Videos

No response

Platform

  • Router / Start Version: [e.g. 1.121.0]
  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Browser Version: [e.g. 91.1]
  • Bundler: [e.g. vite]
  • Bundler Version: [e.g. 7.0.0]

Additional context

No response

  1. the example seems to run, but it just because the server (express) is using a wildcard to catch all routes and not only the basepath

  2. @schiller-manuel you rock man!

Sign in to join this conversation.