Skip to content

Unable to override basepath for api routes #3080

Closed
@aarjithn

Description

@aarjithn

Which project does this relate to?

Start

Describe the bug

It is sometimes required to setup tanstack start app with a basepath.
For the router, it is possible to pass a basepath to createTanStackRouter
For server fns, it is possible to set this in app.config.ts

  routers: {
    server: {
      base: '/path/_server',
    },

However, the config apiBase doesn't seem to work with a custom basepath.

tsr: {
    apiBase: '/api',
    // apiBase: '/path/api', <- throws 503 Server unavailable
  },

And this makes it impossible to define api routes inside a subpath.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-rfnhqhpv?file=app.config.ts

Steps to Reproduce the Bug or Issue

  1. In attached stackblitz, update apiBase with a base url (uncomment line 25 - /path/api)
  2. Note error 503 Server Unavailable

Expected behavior

Should be able to provide a custom basepath for api routes, like the router itself

Screenshots or Videos

Image

Platform

  • OS: macOS
  • Browser: Chrome

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThis issue is about a user needing insightstartEverything about TanStack Start

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions