Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ program
if (options.port) {
const sessions = new Map<string, SSEServerTransport>();
const httpServer = http.createServer(async (req, res) => {
const url = new URL(req.url ?? '', `http://${req.headers.host}`);
Copy link
Contributor

@mxschmitt mxschmitt Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const url = new URL(req.url ?? '', `http://${req.headers.host}`);
const url = new URL(`http://${req.headers.host || 'localhost'}${req.url || ''}`;);

what about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be exactly the same, because req.url is always absolute.

if (req.method === 'POST') {
const host = req.headers.host ?? 'http://unknown';
const sessionId = new URL(host + req.url!).searchParams.get('sessionId');
const sessionId = url.searchParams.get('sessionId');
if (!sessionId) {
res.statusCode = 400;
res.end('Missing sessionId');
Expand Down