Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Stuck on another 404 Issue on prod

default discord avatar
notchr2 years ago
4

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



@364562745447940099

Anything look weird there?

  • discord user avatar
    seanzubrickas
    2 years ago

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

  • default discord avatar
    notchr2 years ago

    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

    @858693520012476436

    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)

  • discord user avatar
    seanzubrickas
    2 years ago

    interesting...good work!

  • default discord avatar
    notchr2 years ago

    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 dedicated engineering support directly from the Payload team.