#POST api auth signin provider
1 messages · Page 1 of 1 (latest)
I think so
I was able to achieve something kinda working by adding a /pages/signin.js and specifying it in the pages.signIn config, than using a client-side redirect, but it looks dirty to me. If I developed it from scratch (say with express) I would rather send a proper redirect directly from the server. Don't u agree?
Not sure
Obviously having to go to the client first isn’t ideal
NextAuth.js exposes a REST API that is used by the NextAuth.js client.
thanks @fast path
The post request prob gives me a redirect url you can use
But I have no experience with it
but I think I am being able to obtain what I am trying to (how middleware and [...nextauth].js interact is kinda strange)
I don't like the idea of the POST
I am trying to solve it differently
How else would you redirect?
If you don’t know where they got to go to?
The only other way would you to manually get your oauth url and manually redirect to it via hardcoded
I found that if I set the pages.signIn prop in [...nextauth].js to the external provider now it works
what I don't quite grasp is the relation between the pages prop in the middleware vs in the [...nextaut].js file
the latter seems to be the one that decides, in the end
Pages prop in middleware?
currently I had this:
export {default} from 'next-auth/middleware'
export const config = {
matcher: ['/restricted'],
pages: {
signIn: 'http://pdb.local/accounts/login',
error: '/api/auth/error',
},
}
did I get it wrong?
not sure, maybe I got it wrong
that makes sense
but I am sure it was kinda working (I already asked a question here on discord couple days ago)
btw, if [...nextauth].js is the way to go I will follow that route and see if I can achieve what I am trying to
yes, makes sense. I don't have a deep understanding of how nextjs works yet
btw in the next-auth docs there is a reference to a pages prop in the middleware: https://next-auth.js.org/configuration/nextjs#pages
unstable_getServerSession
this is what was (and still is ) confusing me
yeah, but they behave kinda differently (ie: middleware seems to be statically looked by webpack, or something like that, so it behaves weirdly with JS inside of it...)
ok, makes kinda sense 😅
anyhow it makes it behave in unexpected ways, in my opinion (https://discord.com/channels/752553802359505017/1104155577220857997)