Astro server endpoints with nodejs adapter has empty header
I am following this tutorial: [Astro with Firebase][1]https://ift.tt/nDzfRLM and everything works as expected after I run npm run dev
. However when I run npm run build
and start the server with node ./dist/server/entry.mjs
I am not able to access headers from the request sent to server. Here is the server endpoint code:
export const get: APIRoute = async ({ request, cookies, redirect }) => {
/* Get token from header*/
const idToken = request.headers.get("Authorization")?.split("Bearer ")[1];
if (!idToken) //idToken null
{
return new Response(
"No token found",
{ status: 401 }
);
}
...
return redirect("/dashboard");
};
I am running newest version of Astro with SSR nodejs (hybrid rendering.
So far I tried:
- Use axios instead of request for HTTP get request
- Different version of node (18 /20)
- Add token as a param after my base url (localhost:3000/api/auth?token) - it seems that only plain URL is available on the server side.
Thanks for any ideas.
Comments
Post a Comment