Managing Cookies When Running On Local Host

default discord avatar
aaronksaunders
2 months ago
1 4

I have my payloadCMS running on port 3100 and my nuxt client app running on port 3000. I am running everything locally on localhost.

Whenever I log in to the admin console it drops a new payload-token cookie which then overwrites the payload-token cookie for the currently logged-in user making it difficult to work in CMS and test my application locally

Is there a solution to this?

Thanks... after a couple of early stumbles I am getting the hang of PayloadCMS and it is pretty awesome

https://discord.com/channels/967097582721572934/1153409343568498718

  • default discord avatar
    aaronksaunders
    2 months ago

    just using two separate tabs/browsers

  • default discord avatar
    matthijs166
    2 months ago

    Maybe you can try the following:

    You can edit your host file (/etc/hosts) for example:
    127.0.0.1. payload.dev
    Open your admin panel on http://payload.dev:3100 and point the frond end to http://localhost:3000.
    I think this way the cookies won't mix.

    Also, a solution is to open up an incognito window.

    And maybe good practice to handle the admin user like a normal user in the frond end, then there is no need to log in with two separate accounts.

  • default discord avatar
    aaronksaunders
    2 months ago
    1 reply
    default discord avatar
    matthijs166
    2 months ago

    Ahh I feel you! Had that problem also a while back. So my solution was an incognito window.

  • default discord avatar
    matthijs166
    2 months ago

    Maybe a future plugin idea: Payload Impersonation plugin

    Would love to have a plugin like this: https://wordpress.org/plugins/user-switching/

Open the post
Continue the discussion in GitHub
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.