Skip to content

Commit bbea05b

Browse files
committed
only check for /
1 parent bb8d557 commit bbea05b

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/http/handlers/html.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import type { TidewaveConfig } from '../../core';
22
import type { TidewaveHandler, TidewaveNext, TidewaveRequest, TidewaveResponse } from '../types';
33

44
export function createHandleHtml(config: TidewaveConfig): TidewaveHandler {
5-
return createHtmlHandler(config, 'tc.js', {
6-
pathnames: ['', '/', '/tidewave'],
7-
});
5+
return createHtmlHandler(config, 'tc.js', {});
86
}
97

108
export function createHandleAppHtml(config: TidewaveConfig): TidewaveHandler {
119
return createHtmlHandler(config, 'control.js', {
12-
pathnames: ['', '/', '/app', '/tidewave/app'],
1310
headers: {
1411
'Content-Security-Policy': "base-uri 'self'; frame-ancestors 'self';",
1512
},
@@ -19,7 +16,7 @@ export function createHandleAppHtml(config: TidewaveConfig): TidewaveHandler {
1916
function createHtmlHandler(
2017
config: TidewaveConfig,
2118
script: 'tc.js' | 'control.js',
22-
options: { headers?: Record<string, string>; pathnames: string[] },
19+
options: { headers?: Record<string, string> },
2320
): TidewaveHandler {
2421
return async function handleHtml(
2522
req: TidewaveRequest,
@@ -30,8 +27,8 @@ function createHtmlHandler(
3027
const url = req.url || '/';
3128
const pathname = url.split('?')[0] || '';
3229

33-
// Different connect-style middleware stacks may strip different URL prefixes.
34-
if (!options.pathnames.includes(pathname)) {
30+
// Vite strips the prefix passed to server.use, so we can always check /
31+
if (pathname !== '/') {
3532
return next();
3633
}
3734

0 commit comments

Comments
 (0)