Refresh token problem

default discord avatar
last month

I think this might be a tricky one to diagnose, but I suddenly seem to have a problem with my local site that I wasn't having on Friday.

When I log in to the site running on localhost, it makes a POST request to /api/users/refresh-token, which produces a 404 and then logs me out.

I'm using the next-payload module to run Payload within my NextJS site, and one of the last things I did was to move the public-facing pages of my site to the old-style pages directory (rather than app) and to implement a preview mode, via /api/preview, so either of those changes could have been responsible I imagine, but a couple of things are confusing me a little:

1. I can see a generated file under /pages/api/[collection]/refresh.ts but the request is for /api/users/refresh-token, so how does this match up?

2. The site is deployed to Vercel and it seems to work fine. That site doesn't make any request to /api/users/refresh-token at all

As I say, I think this might be a difficult one to solve as there seem to be a lot of variables, and probably I've misunderstood how Payload or NextJS works, but if anyone can suggest something to look at or explain why I might be seeing these things it would be much appreciated.

  • discord user avatar
    Payload Team
    4 weeks ago

    I think you are correct! The page name should likely be


    and not

  • default discord avatar
    last week

    Hi @Jarrod this problem went away for a while but has now returned. I can't log in to my local version of the site. I tried renaming the file from refresh.ts to refresh-token.ts but that changed the error from a 404 to a 403 so I'm guessing it's more complicated than that? I've also updated Payload to 1.8.2. Any ideas what I might be able to do?

  • discord user avatar
    Payload Team
    last week

    Yep, thank you for being persistent. Confirmed bug (inside next-payload), fixed on main - will release today

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


Connect with the Payload Community on Discord



Can't find what you're looking for?

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