How to get the full headers when serving the html files according to the request body

I am trying to get the headers of the request and from our app i am sending authorization and geopoints but when i am logging the headers it gives an array of objects where 16 objects are there i am using this to log the headers
let requestHeaders = JSON.stringify([…request.headers])
console.log(new Map(request.headers))
and here is the code which i have tried

const html = `


header is empty

`; const html1 = ` Document

header is not empty

`; addEventListener("fetch", (event) => { return event.respondWith(handleRequest(event.request)); }); async function handleRequest(request) { let requestHeaders = JSON.stringify([...request.headers]); console.log(new Map(request.headers)); console.log(requestHeaders); if (Object.keys(request.headers).length === 0) { console.log("no header"); return new Response(html, { headers: { "content-type": "text/html;charset=UTF-8", }, }); } // else{ return new Response(html1, { headers: { "content-type": "text/html;charset=UTF-8", }, }); }

Are you developing your app using Cloudflare Workers?

no it’s like when someone scans a qr code it will send them to this URL and in the url’s header we are sending geopoint and authorization

I assume you are using Node.js?

This topic was automatically closed after 31 days. New replies are no longer allowed.