chore: parse search params the usual way (#78)

This commit is contained in:
Pavel Feldman 2025-03-28 13:41:08 -07:00 committed by GitHub
parent 7bda082a4e
commit 195ed4a4ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,8 +89,8 @@ async function startSSEServer(port: number, serverList: ServerList) {
const sessions = new Map<string, SSEServerTransport>(); const sessions = new Map<string, SSEServerTransport>();
const httpServer = http.createServer(async (req, res) => { const httpServer = http.createServer(async (req, res) => {
if (req.method === 'POST') { if (req.method === 'POST') {
const host = req.headers.host ?? 'http://unknown'; const searchParams = new URL(`http://localhost${req.url}`).searchParams;
const sessionId = new URL(host + req.url!).searchParams.get('sessionId'); const sessionId = searchParams.get('sessionId');
if (!sessionId) { if (!sessionId) {
res.statusCode = 400; res.statusCode = 400;
res.end('Missing sessionId'); res.end('Missing sessionId');