Skip to content

Commit 56f1c7b

Browse files
committed
Add comment about prepending localhost
1 parent b95e343 commit 56f1c7b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

library/helpers/matchEndpoint.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export function matchEndpoint(context: LimitedContext, endpoints: Endpoint[]) {
2929
return undefined;
3030
}
3131

32+
// req.url is relative, so we need to prepend a host to make it absolute
33+
// We just match the pathname, we don't use the host for matching
3234
const url = tryParseURL(
3335
context.url.startsWith("/") ? `http://localhost${context.url}` : context.url
3436
);

library/sources/http-server/contextFromRequest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export function contextFromRequest(
1212
let parsedURL: URL | undefined = undefined;
1313
if (req.url) {
1414
try {
15+
// req.url is relative, so we need to prepend a host to make it absolute
16+
// We just need the searchParams, we don't use the host
1517
parsedURL = new URL(
1618
req.url.startsWith("/") ? `http://localhost${req.url}` : req.url
1719
);

0 commit comments

Comments
 (0)