diff --git a/e2e/solid-start/custom-basepath/src/routeTree.gen.ts b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts index 6064fd7604f..1a94469caaf 100644 --- a/e2e/solid-start/custom-basepath/src/routeTree.gen.ts +++ b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts @@ -11,11 +11,14 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as UsersRouteImport } from './routes/users' import { Route as PostsRouteImport } from './routes/posts' +import { Route as LogoutRouteImport } from './routes/logout' import { Route as DeferredRouteImport } from './routes/deferred' import { Route as IndexRouteImport } from './routes/index' import { Route as UsersIndexRouteImport } from './routes/users.index' +import { Route as RedirectIndexRouteImport } from './routes/redirect.index' import { Route as PostsIndexRouteImport } from './routes/posts.index' import { Route as UsersUserIdRouteImport } from './routes/users.$userId' +import { Route as RedirectThrowItRouteImport } from './routes/redirect.throw-it' import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' import { Route as ApiUsersRouteImport } from './routes/api/users' import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep' @@ -31,6 +34,11 @@ const PostsRoute = PostsRouteImport.update({ path: '/posts', getParentRoute: () => rootRouteImport, } as any) +const LogoutRoute = LogoutRouteImport.update({ + id: '/logout', + path: '/logout', + getParentRoute: () => rootRouteImport, +} as any) const DeferredRoute = DeferredRouteImport.update({ id: '/deferred', path: '/deferred', @@ -46,6 +54,11 @@ const UsersIndexRoute = UsersIndexRouteImport.update({ path: '/', getParentRoute: () => UsersRoute, } as any) +const RedirectIndexRoute = RedirectIndexRouteImport.update({ + id: '/redirect/', + path: '/redirect/', + getParentRoute: () => rootRouteImport, +} as any) const PostsIndexRoute = PostsIndexRouteImport.update({ id: '/', path: '/', @@ -56,6 +69,11 @@ const UsersUserIdRoute = UsersUserIdRouteImport.update({ path: '/$userId', getParentRoute: () => UsersRoute, } as any) +const RedirectThrowItRoute = RedirectThrowItRouteImport.update({ + id: '/redirect/throw-it', + path: '/redirect/throw-it', + getParentRoute: () => rootRouteImport, +} as any) const PostsPostIdRoute = PostsPostIdRouteImport.update({ id: '/$postId', path: '/$postId', @@ -80,12 +98,15 @@ const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({ export interface FileRoutesByFullPath { '/': typeof IndexRoute '/deferred': typeof DeferredRoute + '/logout': typeof LogoutRoute '/posts': typeof PostsRouteWithChildren '/users': typeof UsersRouteWithChildren '/api/users': typeof ApiUsersRouteWithChildren '/posts/$postId': typeof PostsPostIdRoute + '/redirect/throw-it': typeof RedirectThrowItRoute '/users/$userId': typeof UsersUserIdRoute '/posts/': typeof PostsIndexRoute + '/redirect': typeof RedirectIndexRoute '/users/': typeof UsersIndexRoute '/api/users/$userId': typeof ApiUsersUserIdRoute '/posts/$postId/deep': typeof PostsPostIdDeepRoute @@ -93,10 +114,13 @@ export interface FileRoutesByFullPath { export interface FileRoutesByTo { '/': typeof IndexRoute '/deferred': typeof DeferredRoute + '/logout': typeof LogoutRoute '/api/users': typeof ApiUsersRouteWithChildren '/posts/$postId': typeof PostsPostIdRoute + '/redirect/throw-it': typeof RedirectThrowItRoute '/users/$userId': typeof UsersUserIdRoute '/posts': typeof PostsIndexRoute + '/redirect': typeof RedirectIndexRoute '/users': typeof UsersIndexRoute '/api/users/$userId': typeof ApiUsersUserIdRoute '/posts/$postId/deep': typeof PostsPostIdDeepRoute @@ -105,12 +129,15 @@ export interface FileRoutesById { __root__: typeof rootRouteImport '/': typeof IndexRoute '/deferred': typeof DeferredRoute + '/logout': typeof LogoutRoute '/posts': typeof PostsRouteWithChildren '/users': typeof UsersRouteWithChildren '/api/users': typeof ApiUsersRouteWithChildren '/posts/$postId': typeof PostsPostIdRoute + '/redirect/throw-it': typeof RedirectThrowItRoute '/users/$userId': typeof UsersUserIdRoute '/posts/': typeof PostsIndexRoute + '/redirect/': typeof RedirectIndexRoute '/users/': typeof UsersIndexRoute '/api/users/$userId': typeof ApiUsersUserIdRoute '/posts_/$postId/deep': typeof PostsPostIdDeepRoute @@ -120,12 +147,15 @@ export interface FileRouteTypes { fullPaths: | '/' | '/deferred' + | '/logout' | '/posts' | '/users' | '/api/users' | '/posts/$postId' + | '/redirect/throw-it' | '/users/$userId' | '/posts/' + | '/redirect' | '/users/' | '/api/users/$userId' | '/posts/$postId/deep' @@ -133,10 +163,13 @@ export interface FileRouteTypes { to: | '/' | '/deferred' + | '/logout' | '/api/users' | '/posts/$postId' + | '/redirect/throw-it' | '/users/$userId' | '/posts' + | '/redirect' | '/users' | '/api/users/$userId' | '/posts/$postId/deep' @@ -144,12 +177,15 @@ export interface FileRouteTypes { | '__root__' | '/' | '/deferred' + | '/logout' | '/posts' | '/users' | '/api/users' | '/posts/$postId' + | '/redirect/throw-it' | '/users/$userId' | '/posts/' + | '/redirect/' | '/users/' | '/api/users/$userId' | '/posts_/$postId/deep' @@ -158,9 +194,12 @@ export interface FileRouteTypes { export interface RootRouteChildren { IndexRoute: typeof IndexRoute DeferredRoute: typeof DeferredRoute + LogoutRoute: typeof LogoutRoute PostsRoute: typeof PostsRouteWithChildren UsersRoute: typeof UsersRouteWithChildren ApiUsersRoute: typeof ApiUsersRouteWithChildren + RedirectThrowItRoute: typeof RedirectThrowItRoute + RedirectIndexRoute: typeof RedirectIndexRoute PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute } @@ -180,6 +219,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof PostsRouteImport parentRoute: typeof rootRouteImport } + '/logout': { + id: '/logout' + path: '/logout' + fullPath: '/logout' + preLoaderRoute: typeof LogoutRouteImport + parentRoute: typeof rootRouteImport + } '/deferred': { id: '/deferred' path: '/deferred' @@ -201,6 +247,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof UsersIndexRouteImport parentRoute: typeof UsersRoute } + '/redirect/': { + id: '/redirect/' + path: '/redirect' + fullPath: '/redirect' + preLoaderRoute: typeof RedirectIndexRouteImport + parentRoute: typeof rootRouteImport + } '/posts/': { id: '/posts/' path: '/' @@ -215,6 +268,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof UsersUserIdRouteImport parentRoute: typeof UsersRoute } + '/redirect/throw-it': { + id: '/redirect/throw-it' + path: '/redirect/throw-it' + fullPath: '/redirect/throw-it' + preLoaderRoute: typeof RedirectThrowItRouteImport + parentRoute: typeof rootRouteImport + } '/posts/$postId': { id: '/posts/$postId' path: '/$postId' @@ -285,9 +345,12 @@ const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren( const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, DeferredRoute: DeferredRoute, + LogoutRoute: LogoutRoute, PostsRoute: PostsRouteWithChildren, UsersRoute: UsersRouteWithChildren, ApiUsersRoute: ApiUsersRouteWithChildren, + RedirectThrowItRoute: RedirectThrowItRoute, + RedirectIndexRoute: RedirectIndexRoute, PostsPostIdDeepRoute: PostsPostIdDeepRoute, } export const routeTree = rootRouteImport diff --git a/e2e/solid-start/custom-basepath/src/routes/logout.tsx b/e2e/solid-start/custom-basepath/src/routes/logout.tsx new file mode 100644 index 00000000000..7e13279beed --- /dev/null +++ b/e2e/solid-start/custom-basepath/src/routes/logout.tsx @@ -0,0 +1,32 @@ +import { createFileRoute, redirect } from '@tanstack/solid-router' +import { createServerFn } from '@tanstack/solid-start' + +const logoutFn = createServerFn({ + method: 'POST', +}).handler(async () => { + // do logout stuff here + throw redirect({ + to: '/', + }) +}) + +export const Route = createFileRoute('/logout')({ + component: Home, +}) + +function Home() { + return ( +
+ This form tests that server function URLs correctly include the app's + basepath. The form action should be '/custom/basepath/_serverFn/...' not + just '/_serverFn/...' +
+ +