2 years ago
In my express app deployed to railway, in the following middleware, the first console.log outputs the request body correctly but the second one outputs an empty string. What gives? It works fine locally.
Project ID: d414d846-9e9b-45fe-b52f-1fa28e8426ae
Node image: node:22.12.0-alpine
Express version: 5.0.1
export default function requestLogger(
req,
res,
next
) {
express.raw({ type: "*/*" })(req, res, () => {
const body = req.body.toString();
console.log("body: ", body);
console.log(body);
});
next();
}18 Replies
2 years ago
I'm sorry but we wouldn't be able to provide coding support here
2 years ago
Perhaps it's accidentally turning into structured logs
click on the + button on the side, your info may be appearing there

2 years ago
it is not a bug on Railway's side, it is also not productive to place the blame on the platform
2 years ago
then it is turning into structured logs
how do you know it's not a bug on railway's side. Do you know the solution?
2 years ago
you can see the {"x": 5} is attached as metadata into the empty log string
2 years ago
no problem
2 years ago
maybe not, but explaining JSON is definitely not platform support
by the way, can I disable this structured logging thing? I'll check the docs
explaining why I need to click an extra button to see the result of console.log in the logs is platform support
2 years ago
Not directly, just make sure you're not outputting valid JSON directly, or use a logging library like winston
2 years ago
haha no not really
2 years ago
!s
