diff --git a/sip-dial-plan.ts b/sip-dial-plan.ts index b419a70..0d57ae9 100644 --- a/sip-dial-plan.ts +++ b/sip-dial-plan.ts @@ -84,8 +84,11 @@ async function readDialPlan(): Promise { } // ---------------------------------------------------------------------------- -async function getDialPlan(qs: URLSearchParams): Promise { - const token = qs.get("jwt"); +async function getDialPlan(req: Request): Promise { + const authHeader = req.headers.get("authorization"); + if (!authHeader) return emptyList(); + + const token = authHeader.replace("Bearer ", ""); if (!token) return emptyList(); let jwt: Payload; @@ -123,12 +126,11 @@ async function getDialPlan(qs: URLSearchParams): Promise { async function handler(req: Request): Promise { const url = new URL(req.url); const path = url.pathname; - const qs = new URLSearchParams(url.search); if (req.method !== "GET" && req.method !== "HEAD") return methodNotAllowed(); if (path !== "/get-dial-plan") return notFound(); - return await getDialPlan(qs); + return await getDialPlan(req); } // ----------------------------------------------------------------------------