#No req body in AWS EC2
46 messages · Page 1 of 1 (latest)
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
Do you have anything in your payload config regarding the cookie?
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
Really odd. We have many deploys of payload on VMs using nginx and do not run into this issue.
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:
- Fresh payload CMS install
- Empty database
- Deploy on AWS EC2, run yarn serve after turning on mongodb
- Create something, anything except datatypes that require no authentication.
- 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
Which version is the one you used in your deployed EC2?
Let's continue this on the GH discussion
Yeah sure
Nice, what was the solution?