#POST api auth signin provider

1 messages · Page 1 of 1 (latest)

urban crest
#

having to use a POST already means I am not redirecting to it, doesn't it?

fast path
#

I think so

urban crest
#

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?

fast path
#

Not sure

#

Obviously having to go to the client first isn’t ideal

urban crest
#

thanks @fast path

fast path
#

The post request prob gives me a redirect url you can use

#

But I have no experience with it

urban crest
#

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

fast path
#

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

urban crest
#

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

fast path
#

Pages prop in middleware?

urban crest
#

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?

fast path
#

Where did it say it had pages prop?

#

I don’t ever remember docs saying that

urban crest
#

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

fast path
#

Next auth is just your auth provider

#

Middleware is separate

urban crest
#

yes, makes sense. I don't have a deep understanding of how nextjs works yet

urban crest
#

this is what was (and still is ) confusing me

fast path
#

Oh weird

#

May just be a smell that you need both if ur using middleware for auth

urban crest
#

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

fast path
#

Don’t know

#

Middleware is at the edge

#

So it’s not the same runtime as node

urban crest
#

ok, makes kinda sense 😅

fast path
#

Well

#

I know the marcher has to be statically typed

#

Matcher

#

So I bet that does too