I have a NextJS + Payload CMS app being deployed on Vercel. It is based on this starter template:
https://github.com/payloadcms/nextjs-custom-server.
I'm not sure if this issue is because of the environment variables, but I have the same as the one in my local (
http://localhost:3000
is the value of
PAYLOAD_PUBLIC_SERVER_URL
and
NEXT_PUBLIC_SERVER_URL
). I tried setting both of them equal to
https://payload-nextjs-practice.vercel.app
which is the prod URL, but it didn't work.
I validated the
MONGODB_URI
and
PAYLOAD_SECRET
variables, and they're all the same both in my local and in prod.
This is the log from Vercel when trying to go to
/admin
in prod:
APIError: The collection with slug pages can't be found.
at new ExtendableError (/var/task/node_modules/payload/dist/errors/APIError.js:22:15)
at new APIError (/var/task/node_modules/payload/dist/errors/APIError.js:38:9)
at findLocal (/var/task/node_modules/payload/dist/collections/operations/local/find.js:16:15)
at BasePayload.find (/var/task/node_modules/payload/dist/payload.js:53:20)
at getServerSideProps (/var/task/.next/server/pages/[...slug].js:662:56)
at /var/task/node_modules/next/dist/server/render.js:508:110
at /var/task/node_modules/next/dist/server/lib/trace/tracer.js:66:32
at NoopContextManager.with (/var/task/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7054)
at ContextAPI.with (/var/task/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:517)
at NoopTracer.startActiveSpan (/var/task/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18022) {
status: 500,
data: null,
isPublic: false,
isOperational: true,
page: '/admin'
}
RequestId: 85b732a5-7104-4aa2-b3ed-80bc106b494e Error: Runtime exited with error: exit status 1
Runtime.ExitError
Not super familiar with vercel but
You set your server url initially to localhost:3000
but then you used
https://payload-nextjs-practice.vercel.app
Are you pointing it at port :3000 on vercel
yes, it is pointing at that same port
In prod I'm pretty sure you have to run the build command first then add a new variable NODE_ENV=production
It's possible they aren't running with payload prod instance with npm run serve
Which then wouldnt include that prod env
@Juan Sebastián Mendoza vercel does not host custom servers, you would have to host this approach another way - like DigitalOcean. There are a couple other ways to host Payload, we have our newly released cloud platform that you could try, we also released our serverless approach that can be deployed on vercel alongside NextJS
Cloud:
https://payloadcms.com/newServerless approach:
https://github.com/payloadcms/next-payloadStar
Discord
online
Get help straight from the Payload team with an Enterprise License.