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.

Good morning everyone! When I'm making a request f...

discord user avatar
dribbens
last year
4

Hey

@217300665473564672


Try changing the "Authorization" header to

JWT ${token}

instead of

Bearer ${token}

.



I don't think the Cookie is doing anything, could try without that also.

  • default discord avatar
    igormfelast year

    Like so?



    const response = await fetch(

    ${url}/api/users/${userId}

    , { method: 'PATCH', headers: { "Content-Type": 'application/json', "Authorization":

    JWT ${token}

    , }, accept: 'application/json', body: body, });

    That still didn't work



    My validation works as follows:



    import { Access } from 'payload/config';



    export const isAdminOrSelf: Access = ({ req: { user } }) => { // Need to be logged in if (user) { if (user.roles?.includes('admin')) { return true; } // If any other type of user, only provide access to themselves return { id: { equals: user.id, }, }; } // Reject everyone else return false; };

    I checked for token and userId both being valid, and I get a proper response back:



    {"userId":"6537d55f2611dba8e2ff8d3a","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3Q0QHRlc3QudGVzdCIsImlkIjoiNjUzN2Q1NWYyNjExZGJhOGUyZmY4ZDNhIiwiY29sbGVjdGlvbiI6InVzZXJzIiwicm9sZXMiOlsidXNlciJdLCJpYXQiOjE2OTgxNTkwNDEsImV4cCI6MTY5ODE2NjI0MX0.rPM5poLd040ZRg9y94osJVOF8_0x9XlRc7f6jhvOm9Y","expiration":1699857207141}
  • discord user avatar
    dribbens
    last year

    Are you getting a CORS error? Requests from another domain need to be explicitly added to the cors array in your config.

  • default discord avatar
    igormfelast year

    I'm not, I'm just getting the access error





    I've already added the webflow domain



    I think I migh be onto something, one second



    Issue might not be here, but on the login token storage



    Also, I've added a payment method a few days ago but the error message of "add a payment method" still appears on the payload website



    There we go, it works now. The issue was the storage somehow got lost in the event handler



    Thanks!

  • discord user avatar
    dribbens
    last year

    🎉

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.