Skip to content
Merged
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
1 change: 1 addition & 0 deletions examples/react/start-basic-static/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NotFound } from './components/NotFound'
export function getRouter() {
const router = createRouter({
routeTree,
basepath: '/test/',
defaultPreload: 'intent',
defaultErrorComponent: DefaultCatchBoundary,
defaultNotFoundComponent: () => <NotFound />,
Expand Down
1 change: 1 addition & 0 deletions examples/react/start-basic-static/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import viteReact from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
base: '/test/',
server: {
port: 3000,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/start-plugin-core/src/prerender.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promises as fsp } from 'node:fs'
import os from 'node:os'
import path from 'pathe'
import { joinURL, withBase, withoutBase } from 'ufo'
import { joinURL, withBase, withTrailingSlash, withoutBase } from 'ufo'
import { VITE_ENVIRONMENT_NAMES } from './constants'
import { createLogger } from './utils'
import { Queue } from './queue'
Expand Down Expand Up @@ -164,7 +164,7 @@ export async function prerender({
// Fetch the route

const res = await localFetch(
withBase(page.path, routerBasePath),
withTrailingSlash(withBase(page.path, routerBasePath)),
{
headers: {
...(prerenderOptions.headers ?? {}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { pathToFileURL } from 'node:url'
import { basename, extname, join } from 'pathe'
import { NodeRequest, sendNodeResponse } from 'srvx/node'
import { joinURL } from 'ufo'
import { VITE_ENVIRONMENT_NAMES } from '../constants'
import { getServerOutputDirectory } from '../output-directory'
import type { Plugin } from 'vite'
Expand Down Expand Up @@ -43,6 +44,9 @@ export function previewServerPlugin(): Plugin {
serverBuild = imported.default
}

// Prepend base path to request URL to match routing setup
req.url = joinURL(server.config.base, req.url ?? '/')

const webReq = new NodeRequest({ req, res })
const webRes: Response = await serverBuild.fetch(webReq)

Expand Down
Loading