#Weird SSR error

5 messages · Page 1 of 1 (latest)

urban plover
#

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")

https://github.com/jazzypants1989/astro-solid-blog/blob/1d0fda6ae6ea167026c11262b2a0c3121fb44c7d/src/layouts/Layout.astro#L14

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.

tawdry sable
#

Dang. It looks like you're right. I took it down to an index.astro file with nothing in it and it built correctly. Ugh. I guess I'll have to go through taking one thing out at a time until I find the culprit. Thank you for your patient response.

Sorry for the confusing code-- there are a lot of half-implemented concepts in there. I was just playing around with the auth flow, trying to figure out how to redirect users through and bring them back. The original plan was to simply have a link, however my link redirected people to /api/auth/ when only /api/auth actually completed the process. I noticed that a redirect worked at not including the trailing slash, so I changed the login to a button with a function associated to a redirect. You can find the button on line 45 and the event listener on line 26. You're correct that the Astro redirect currently does nothing.

The cookie was a mistake. It was the last thing added to the code right before I started getting errors. It isn't even getting applied before the code hangs up on that error. I've always used express middleware for things like this, so I was just trying to figure out how everything worked when doing it manually.

Thanks for the example repo!

tawdry sable
#

OMG I just fixed it

urban plover
#

Welcome, yeah Auth flow is not easy, it took me quite some time to experience it. I can review once you progress.

tawdry sable
#

it was mad about an unused import in the oauth API route. That is an AWFUL error message. No context whatsoever.