Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Authenticating an app in Payload Beta

default discord avatar
klobleolast month

I've been banging my head against a wall for a couple of days now but I'm really struggling with integrating auth correctly in the V3 beta. I'm creating the payload object with const payload = await getPayloadHMR({ config: payloadConfig })



Then I have no idea what to pass in payload.auth() all of the docs say its req, res but I'm assuming thats changed since the move to Next as that's not available? if anyone could point me in the right direction that would be incredible.



Just as a note I'm doing this within an api route in my custom app. And a user has been created and the payload-token JWT / HTTP Cookie has been created



For anyone else that needs help with it... Although it might just be me being dense... here's the solution:



const payload = await getPayloadHMR({ config: payloadConfig })


const user = await payload.auth({ headers: request.headers })

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.