Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-taxes-feel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/start-server-core': minor
---

less unnecessary creation of URL
8 changes: 2 additions & 6 deletions packages/router-core/src/ssr/createRequestHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { createMemoryHistory } from '@tanstack/history'
import { mergeHeaders } from './headers'
import {
attachRouterServerSsrUtils,
getNormalizedURL,
getOrigin,
} from './ssr-server'
import { attachRouterServerSsrUtils, getNormalizedURL } from './ssr-server'
import type { HandlerCallback } from './handlerCallback'
import type { AnyHeaders } from './headers'
import type { AnyRouter } from '../router'
Expand Down Expand Up @@ -36,7 +32,7 @@ export function createRequestHandler<TRouter extends AnyRouter>({

// normalizing and sanitizing the pathname here for server, so we always deal with the same format during SSR.
const { url } = getNormalizedURL(request.url, 'http://localhost')
const origin = getOrigin(request)
const origin = url.origin
const href = url.href.replace(url.origin, '')

// Create a history for the router
Expand Down
3 changes: 1 addition & 2 deletions packages/start-server-core/src/createStartHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import {
attachRouterServerSsrUtils,
getNormalizedURL,
getOrigin,
} from '@tanstack/router-core/ssr/server'
import { runWithStartContext } from '@tanstack/start-storage-context'
import { requestHandler } from './request-response'
Expand Down Expand Up @@ -434,7 +433,7 @@ export function createStartHandler<TRegister = Register>(
// in these cases we would prefer to redirect to the new path
const { url, handledProtocolRelativeURL } = getNormalizedURL(request.url)
const href = url.pathname + url.search + url.hash
const origin = getOrigin(request)
const origin = url.origin

if (handledProtocolRelativeURL) {
return Response.redirect(url, 308)
Expand Down
Loading