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.

Refresh token problem

default discord avatar
danmartin30582 years ago
4

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
    jarrod_not_jared
    2 years ago

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

    refresh-token

    and not

    refresh
  • default discord avatar
    danmartin30582 years ago

    Hi

    @281120856527077378

    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
    jarrod_not_jared
    2 years ago

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

  • default discord avatar
    danmartin30582 years ago

    Thanks

    @281120856527077378

    . What's the process for upgrading to the new version, since I already installed next-payload with the older version? I tried just replacing the refresh-token.ts file but it references a src/middleware directory that I don't have, and presumably some other changes as well.



    Actually I might have it sorted. Updated the next-payload module and re-ran the install and it seems to have done the job.

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.