Deployment to Azure or Simple NGINX web host

default discord avatar
mrl7
7 months ago
7

Hey all, I'm having some issues getting the payload server deployed. I have managed to deploy the CMS front end to our basic linux web host. But for some reason, I can't get the API to work at all. I've also tried deploying to Azure web services. That threw out a lot of cors errors which I fixed inside azure but the cors errors still remain.



I've followed through the payload docs but can't seem to make any sense of the deployment process.


When deploying, is there any certain folders that the files need to be placed in? Is there any other config I might be missing?


I am just deploying the build and server files manually via FTP so could very well be missing something.


Can someone help?

  • discord user avatar
    denolfe
    Payload Team
    7 months ago

    In order to deploy Payload, you'll need both the dist and build directory after building.



    I can't get the API to work at all

    Providing more detail here would give more info in order to help. Are you able to hit the API at all? Receiving 5XX/4XX errors? Can you provide the cors errors? Do you have the

    serverURL

    property set in your config?

  • default discord avatar
    mrl7
    7 months ago

    Hey Elliot, I managed to get it working on Friday. I had some ports all wrong which was causing the errors.

  • discord user avatar
    denolfe
    Payload Team
    7 months ago

    @mrl7 Great to hear!

  • default discord avatar
    reynoldputra
    2 months ago

    Hello, can u give more detail about deploying payloadCMS using nginx . Im trying to deploy payloadCMS in ubuntu+nginx. I have moved build files to my nginx so i can access my index.html from browser. But its receiving error 404 when requesting js and css file. If i look into index.html, js and css files is located in admin folder, but i dont see them in my build files.



    sorry I'm just learning how to deploy using nginx


    @denolfe @mrl7

  • discord user avatar
    denolfe
    Payload Team
    2 months ago

    Have a look at the config in this thread. There might be some ideas there:

    https://payloadcms.com/community-help/github/req-and-user-are-undefined-running-behind-nginx-proxy
  • default discord avatar
    reynoldputra
    2 months ago

    Thanks a lot

  • default discord avatar
    tomten73
    2 months ago

    Hi! I'm deploying in the exact same way, nginx reverse proxy that points to the node server that runs locally (EC2 instance, not my machine) on port 3000. However, my issue is a bit different - when i go to mysite.com its successfull but im stuck in an infite loading loop. Looking in the console i get error:


    GET

    http://localhost:3000/api/users/me

    net::ERR_CONNECTION_REFUSED


    Which is strange, cause the payload config has

    serverURL: 'https://mysite.com'

    set and my initial request is successfull and my browser is downloading the js files and hydrating etc etc. So I don't understand why it's trying to communicate with the api like its running on localhost instead of mysite.com?



    Any help would be greatly appreciated!



    EDIT: Apparently setting cors to "*" solved it. Not sure why whitelisting my own domain doesn't work tho.

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.