so you have simply a build error after all, I'm afraid you would just have to be removing code till build succeeds then putting it back.
I can't understand your auth concept though, the redirect in the Layout seems to be unused to me
const redirect = Astro.redirect("/api/auth")
This redirect works for me when a page does not exist
if(!existsSync(page_path)){
console.log(`${page} does not exist`)
return Astro.redirect("/")
}
https://github.com/MicroWebStacks/astro-big-doc/blob/dd2ef27ff03fa649f801f66e7e96a5e7334513b6/src/pages/blog/[...page].astro#L21
and by the way, you can look at that project if still interested to learn about Auth steps, it's different as it is middleware based and using express, I started thinking about Astro Auth but dropped it due to React contamination, as I only found easy to understand examples on express, that's how I starded, it's working now, I think now it should be possible to port to node standalone. You also have secure cookie, I assume you use https then.