#No req body in AWS EC2

46 messages · Page 1 of 1 (latest)

orchid hinge
#

Yesterday I posted an issue here but my issue was actually wrong. I thought it was due to reverse proxy but my reverse proxy was working correctly.

Now I realize that when I turn off nginx, payload still does not pass the req to my authentication functions. Why is this the case?

orchid hinge
#

Description of my configuration:

Both PayloadCMS and my frontend is on the same url,

Nginx reverse proxies to 3000 (My frontend) by default, if the route is /admin or /api it goes to 5000, where my Payload CMS is

#

Nginx is working 100% correctly and it is not the Nginx's fault. I know this because when I turn off nginx and just go to payload cms via port 5000 in the browser I still get the error.

#

I put 22 (SSH) 80, 443 and 5000 as 0.0.0.0 in my AWS security groups

#

My application is running via docker-compose, essentially just 4 docker containers running and connecting to each other

#

Sveltekit server for my frontend, payload, mongodb and nginx, each has a container

#

I can login to payload via www.url.com/admin , once I login I can do nothing, not even logout because everything requires authentication, including logging out.

#

My {req} object passed to my auth functions are faulty.

"req.user is undefined, cannot read "role"" , they are actually empty

cinder briar
#

Do you have anything in your payload config regarding the cookie?

orchid hinge
#
import { buildConfig } from 'payload/config';
import path from 'path';
// import Examples from './collections/Examples';
import Users from './collections/Users';
import CarModels from './collections/CarModels';
import Examples from './collections/Examples';
import CarListings from './collections/CarListings';
import Brands from './collections/Brands';
import PagesTwoColumns from './collections/PagesTwoColumns';

export default buildConfig({
  serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL,
  rateLimit : {
    trustProxy: true
  },
  cors : [
    "*"
  ],
  admin: {
    user: Users.slug,
  },
  collections: [
    Users,
    CarModels,
    CarListings,
    Brands,
    PagesTwoColumns,
    // Add Collections here
    Examples,
  ],
  typescript: {
    outputFile: path.resolve(__dirname, 'payload-types.ts'),
  },
  graphQL: {
    schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
  },
});
#

not really know

#

*no

cinder briar
#

Really odd. We have many deploys of payload on VMs using nginx and do not run into this issue.

orchid hinge
#

Note, that when I run fetch requests

#

GET requests are OK, that is how I am able to login

#

put POST requests, on the same url and endpoints and whatnot, same url string. Do not work

#

they give a server error 500

#

Also Elliot, when I console logged the req in my express.js stuff in /src/server.ts

#

the payload-token is actually there

#

and when I checked the network tab there is no warning sign next to the cookie that contains that token

#

So the token IS going through

#

I will try to deploy it... Not from a container

#

but just deploy it

#

Just reporting

#

When running yarn serve normally without container

#

it DOESNT work

#

it STILL doesn't work

#

Thats it!

#

This time I am going to something even more ambitious

#

FRESH payloadCMS install

#

Tried emptying my database, still doesn't work. After creating first user I cannot create any of my datatypes

#

Maybe maybe I should try the payloadcms official image

#

Nvm there is no such thing

#

@cinder briar I believe this is now a real bug.

Steps to replicate:

  1. Fresh payload CMS install
  2. Empty database
  3. Deploy on AWS EC2, run yarn serve after turning on mongodb
  4. Create something, anything except datatypes that require no authentication.
  5. Get my error
#

@cinder briar Wait, what version is your payload? Could be something messed up with the new versions, am using the new version

orchid hinge
#

Which version is the one you used in your deployed EC2?

cinder briar
#

Let's continue this on the GH discussion

orchid hinge
#

Yeah sure

orchid hinge
#

@cinder briar Fixed it

#

dw I fixed it

cinder briar
#

Nice, what was the solution?

orchid hinge
#

There was no solution...

#

I just reinstalled payload cms

#

That was the solution

#

LMAO