a year 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
a year ago
I'm sorry but we wouldn't be able to provide coding support here
a year ago
Perhaps it's accidentally turning into structured logs
click on the + button on the side, your info may be appearing there

a year ago
it is not a bug on Railway's side, it is also not productive to place the blame on the platform
a year ago
then it is turning into structured logs
a year ago
you can see the {"x": 5} is attached as metadata into the empty log string
a year ago
no problem
a year 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
a year ago
Not directly, just make sure you're not outputting valid JSON directly, or use a logging library like winston
a year ago
haha no not really
a year ago
!s
