Http-only cookies, trying to make it work..

default discord avatar
zeniodev
2 months ago
6

hi, what could be preventing Set-Cookie to set and forward the cookie ? I set credentials: true, tried various cookies options and none working so far but on postman it basically works without problem. I also added csrf cors of front end to the config



Im using a local reverse proxy that is

https://app.local/

and

https://payload.local/

and I added these domain to csrf, I can visit the /me route on browser and get the response but not in my nextjs app, anyone ?



Also I get this Status: 304 Not Modified, not sure whats going on



any help @jarrod_not_jared ? seen you have posted about http cookies sorry for ping

  • discord user avatar
    jarrod_not_jared
    Payload Team
    2 months ago

    Are you doing this in a client component or a RSC

  • default discord avatar
    zeniodev
    2 months ago

    Client



    Wait let me send you the console network log I can see them on browser





    Any chance the local custom https certificate is preventing to set up the cookie ? Not sure but it should work my guess.. but yet still didnt made it to work



    Maybe I need to modify cookies on auth config and tried some combinations but no success. Also csrf and cors are set up to frontend/backend (

    https://app.local

    and

    https://server.local

    )

    Screenshot_2023-07-16_at_19.08.54.png
    Screenshot_2023-07-16_at_19.08.42.png
  • discord user avatar
    jarrod_not_jared
    Payload Team
    2 months ago

    It might be something with your local reverse proxy, but I am unsure



    I assume you are using caddy or similar. Might be nice to throw together a repro (2 repos) so we can take a look.



    and also try without them and see if that is working for you

  • default discord avatar
    zeniodev
    2 months ago

    Should I just add localhost:3000 to csrf for testing without the reverse proxy ?



    Okay thanks for the heads up it works now so the problem is about the reverse proxy but I still have a problem



    Even thought the cooki is included in the header I still gel user: null

  • discord user avatar
    jarrod_not_jared
    Payload Team
    2 months ago

    You added your localhost:3000 to the CSRF?

  • default discord avatar
    zeniodev
    2 months ago

    Okay problem on my side again, “https” instead of http and everything works fine now, sorry for the ping again thanks !!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.