Stuck on another 404 Issue on prod

default discord avatar
thisisnotchrislast year
24

Hello all, trying to resolve an issue on prod where I cant access my payload Admin / API and I get a 404.



I replaced my domain with mywebsite.com in the following as an example:



in my payload config, serverURL: "

https://mywesbite.com

"



Nginx:



    server {
        server_name mywebsite.com;
        root /var/www/mywebsite.com;
        #index index.html index.htm index.nginx-debian.html;
        index index.html;

        location /payload/ {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        location /safsapi/ {
            rewrite ^/safsapi/(.*)$ /$1 break;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:5000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        location / {
            root /var/www/mywebsite.com/client/dist/safs;
            #root /client/dist/safs;
            try_files $uri $uri/ /index.html;
            #index  index.html index.htm;
            index  index.html;
        }
    }


Previously I had no issues hitting /payload and /safsapi routes



Not sure if I accidently changed something while moving to prod



but everything looks the same



Update:



If I add an express route in payload to hit "/payload", I actually hit express and get a "Cannot get /payload"



But still getting 404's on payload api routes



@zubricks Anything look weird there?

  • discord user avatar
    zubricks
    last year

    Let me take a look through this config quick and see if anything looks off

  • default discord avatar
    thisisnotchrislast year

    With that proxy setup



    I tried setting my routes



      routes: {
        api: '/payload/api',
        admin: '/payload/admin',
        graphQL: '/payload/graphql',
        graphQLPlayground: '/payload/graphql-playground'
      }




    SOLUTION



    TY to the amazing @noheadphones



    if you have a reverse proxy



            location /payload/ {
                proxy_buffering off;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:3000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
            }


    proxy_buffering off;


    must be set to off



    (not sure why exactly, but noheadphones is genius)

    image.png
  • discord user avatar
    zubricks
    last year

    interesting...good work!

  • default discord avatar
    thisisnotchrislast year

    Also



    In my situation, if this helps anyone



    I needed to add the following to my payload config



      routes: {
        api: '/payload/api',
        admin: '/payload/admin',
        graphQL: '/payload/graphql',
        graphQLPlayground: '/payload/graphql-playground'
      }
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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