#Build and Deploy a Full Stack E-Commerce App with an Admin Dashboard & CMS in 2024

95 messages · Page 1 of 1 (latest)

late citrus
#

Help Needed: Deploying Payload CMS Project to Vercel with MongoDB

Hi everyone,

I’ve just finished following a tutorial to build a web project using Payload CMS, and everything works fine. However, since it’s currently hosted on a paid plan with Payload, I’m looking to migrate the project to a free hosting solution with MongoDB Atlas for the database and Vercel for web hosting.

What I've done so far:

  1. Copied the Mongo URI from the .env file.
  2. Downloaded the MongoDB Compass GUI to view my MongoDB collections.
  3. Connected to the database using the GUI.
  4. Exported the collections individually as JSON files.
  5. Created a new database (e.g., MongoDB Atlas or AWS) and got the new database URI.
  6. Imported the JSON files as new collections into the new database via the GUI.
  7. Recovered all my database and collections, as well as my assets.

After completing these steps, I copied the required environment variables to Vercel, and the build process succeeded. However, once deployed, the website shows that it your db is currently empty to the database

Problem:

Although the MongoDB connection seems successful, the website indicates a failure to connect once it’s live. I'm not sure where the issue lies, whether it's in the environment variables, database setup, or the connection to Vercel.

Any help would be appreciated! If anyone has experience with Payload CMS, MongoDB, or deploying to Vercel, I'd love to hear your thoughts.

Thanks in advance!

#

Build and Deploy a Full Stack E-Commerce App with an Admin Dashboard & CMS in 2024

late citrus
#

if there is anyone interested into working on a solution together im in, just send a message 🙂

cobalt wyvern
#

What's the problem there? It deployed right and the UI could connect to the database, I think

late citrus
#

Yes but any clue why ?

#

When im in the tutorial environment everything works as expected

#

But once i migrated to vercel i end up with this issue

cobalt wyvern
#

But what's the problem? is the application not connecting to the db? is it not deploying right?

late citrus
#

I dont have any error messages, the connection to the db seems to be ok as you can see in the log. For a reason i dont get, i end up with this template “Payload ecommerce template” after the deployment instead of the website with all the assets

cobalt wyvern
#

did you change that in the index page to not be "Payload ecommerce template"?

late citrus
#

It might be a configuration in the CMS files but I didnt find what is exactly the problem here

#

mmm not sure what are you talking about

#

Can you specify the file ?

#

Did you succeed on migrate the website yourself?

cobalt wyvern
#

index.tsx? I don't use nextjs, it's the one at the base

#

btw, I recommend working on the basics, not doing those

#

deploying is like, supposed to be after a lot of stuff

#

but if you just "copied" everything from a template and deployed it, it's right there

late citrus
#

there is litterally a hundred of file index.tsx in this project

cobalt wyvern
late citrus
#

i think you dont get it right

#

The website works perfectly in the tutorial environment, but it fails to connect when migrating to a free solution with MongoDB Atlas and Vercel.

cobalt wyvern
cobalt wyvern
#

is there any problems in the browser logs or in server logs?

late citrus
#

yes that s why im so confused

#

there is no error anywhere in the build log

cobalt wyvern
#

server log then

late citrus
#

but i still have this genereic template showing instead of the actual website

#

here is my online website

cobalt wyvern
#

the one that is working normally...?

late citrus
#

but its not going to be online tomorrow

#

because This project has a subscription status of past_due on payload

#

and im trying to migrate to a free solution

cobalt wyvern
#

free doesn't exist :d

late citrus
#

vercel + mongo db atlas

cobalt wyvern
#

that's def not free

late citrus
#

?

cobalt wyvern
#

it starts free... until they charge you a lot

#

like, a lot

late citrus
#

ok its not the point here i m not going to debate on this

#

just here to find people who are experiencing the same issue

#

and have been into the project like i did

cobalt wyvern
#

is it getting pushed to vercel automagically?

late citrus
#

you have to deploy manually with your secret files and your mongodb uri

#

then vercel do the rest yes

cobalt wyvern
#

ok, then deploy again

#

and see the build and server logs

late citrus
#

i just copied past the log already

#

all the information i have are already here explain on the top

cobalt wyvern
late citrus
#

do you know payload ?

#

do you work with it ?

cobalt wyvern
#

no, but deploying is deploying.

#

maybe you forgot to deploy recently, that's why I asked for you to deploy again

late citrus
#

have you been through this process with this specific project ?

cobalt wyvern
#

also the server logs would be empty, which helps

late citrus
#

you dont deploy in the same environnemnt

cobalt wyvern
late citrus
#

so its totally different

#

it might work for you on other case

#

but trust me bro not this one

cobalt wyvern
#

it's the same

late citrus
#

ok so what is the solution ?

cobalt wyvern
#

you follow the steps you previously went to find the problem, it's simple

#

you need the server logs, also clean cache would help

late citrus
#

server log ?

#

i just have build and deploy log here

cobalt wyvern
#

logs when your server is running

#

go in your vercel page, it's every provider has a way to find those

#

that's the problem of just blindly following yt tutorials, you need to learn the basics first, then build upon it

late citrus
#

i know i regret to follow those and get trap into a paid environnement

#

first time that i just go into this

#

but you litteraly spend your time to copy past code without trully understanding what you are doing

#

and you end up with something you cannot really migrate at the end for your own portofolio

cobalt wyvern
#

portfolios kinda don't matter if you can't replicate it or even implement part of it alone

late citrus
#

yeah right

#

let me try to redeploy one more time and catch some error in the runtime server log

#

i think i found the view in vercel

#
    at node:internal/deps/undici/undici:13178:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: Error: connect ECONNREFUSED 127.0.0.1:3000
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3000
  }
}```
#

that suggests that the application is trying to connect to localhost instead of my production database.

late citrus
#

have to change the secret key :

NEXT_PUBLIC_SERVER_URL=http://localhost:3000
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000```

by :

```NEXT_PUBLIC_SERVER_URL=https://your-domaine-vercel.vercel.app
PAYLOAD_PUBLIC_SERVER_URL=https://your-domaine-vercel.vercel.app```
#

but now end up with hundred or error from api/graphQL

cobalt wyvern
#

sry, I was working/studying, that took a while

cobalt wyvern
late citrus
#

sadly not yet

#

i still have a tons of error message related to GraphQl API

#

dont know what to do with it

cobalt wyvern
#

wait, what

#

why is it using graphql, is there any big reason for it

late citrus
#

I dont know mate

cobalt wyvern
#

wdym... it's your project :d