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.

New Posts Not Showing on Frontend After Deploying Payload CMS to Vercel

default discord avatar
shadowoff094 months ago
2

Hi! I'm encountering a strange issue with my Payload CMS setup. In my local environment, when I create a new post, it appears immediately after refreshing the page. However, when I deploy the project to Vercel and perform the same steps, the new post doesn't show up on the frontend. Interestingly, when I check the

/api/posts

endpoint, the newly created post is there, but it still doesn't appear in the frontend.



Here's the code for the

/api/posts

endpoint:


import configPromise from '@payload-config'
import { getPayload } from 'payload'

export const GET = async () => {
  const payload = await getPayload({
    config: configPromise,
  })

  const data = await payload.find({
    collection: 'media',
  })

  return Response.json(data)
}


And here's the code responsible for fetching the posts to display on the frontend:


"use server"

import { getPayload } from 'payload'
import config from '@payload-config'

export async function getMedia() {
  const payload = await getPayload({
    config: config,
  });

  const media = await payload.find({
    collection: 'media',
    depth: 1,
    limit: 1000,
  });

  return media;
}


It seems like there's a mismatch between the data fetched from the API and what the frontend displays. Any insights or suggestions on why this might be happening?



New Posts Not Showing on Frontend After Deploying Payload CMS to Vercel



I've used

unstable_noStore()

in the code responsible for fetching the posts to display on the frontend, and it worked!

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.