Skip to content

Commit c559050

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

2 files changed

Lines changed: 6 additions & 9 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

test/http/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('HTTP Utilities', () => {
9898
});
9999

100100
it('should serve the entrypoint page even when an entrypoint query parameter is given', async () => {
101-
const req = { ...createMockRequest(), url: '/tidewave?entrypoint=foo' };
101+
const req = { ...createMockRequest(), url: '/?entrypoint=foo' };
102102
const { res, mockEnd } = createMockResponse();
103103
const next = vi.fn();
104104

@@ -112,7 +112,7 @@ describe('HTTP Utilities', () => {
112112
});
113113

114114
it('should serve the control app with a content security policy', async () => {
115-
const req = { ...createMockRequest(), url: '/tidewave/app' };
115+
const req = { ...createMockRequest(), url: '/' };
116116
const { res, mockEnd, mockSetHeader } = createMockResponse();
117117
const next = vi.fn();
118118

0 commit comments

Comments
 (0)