Deploy Payload on Netlify and vercel

default discord avatar
Daniel502
3 months ago
12

Hello, everyone, hello Payload


i've been trying to deploy my payload website on netlify for a while now but i haven't had any luck. this is the error i've been getting is on the image.


The link to my slug.tsx is here :


https://github.com/neo1415/nem-health/blob/master/pages/%5B...slug%5D.tsx

and as the issue might be with my envs , heres a link to the example.env which is more or less what i'm using :


https://github.com/neo1415/nem-health/blob/master/.env.example

please, i really need help on this

  • default discord avatar
    Sqveeze
    3 months ago

    Have you added your envs in netlify? Issue might be that your fetch doesnt receive the env vars for server url.

  • default discord avatar
    Daniel502
    3 months ago

    yeah i tried that. it's still the same error



    i've added the variables, the error i'm getting now is this

    Screenshot_133.png
  • default discord avatar
    jarrod69420
    3 months ago

    you are trying to build a static site, deploying next and payload on the same server



    chicken and egg problem



    The next and payload deployed as 1 only works when using SSR. Can you tell me what your setup is, are you attempting to deploy next

    and

    payload on netlify?

  • default discord avatar
    Daniel502
    3 months ago

    i'm just trying to get it online so I can view it in production. railway, vercel, netlify. doesn't matter to me right now.



    @jarrod69420 is it impossible to deploy both on the same server ?

  • default discord avatar
    Sqveeze
    3 months ago

    Its possible but what you tryin to do is not possible.


    1) app starts build


    2) app requires some data from basically itself on the /api route


    3) fails cause it cant request data from itself before building and running

  • default discord avatar
    Daniel502
    3 months ago

    So what do you suggest will work

  • default discord avatar
    Sqveeze
    3 months ago

    Use getserversideprops instead of static

  • default discord avatar
    jarrod69420
    3 months ago

    Yep, you can check out this repo:

    https://github.com/payloadcms/nextjs-custom-server
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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