acronie
acronie16mo ago

Bad request in prod but works fine in dev

in prod I am getting BAD REQUEST
17 Replies
acronie
acronieOP16mo ago
No description
acronie
acronieOP16mo ago
Nothing logs on the server If anyone has any idea let me know please I am stuck deploying my application useQuery works fine for now. and other mutations too
Nick
Nick16mo ago
o.from sounds a lot like you’re sending over some bundled JS instead of JSON
acronie
acronieOP16mo ago
bundled js? do I need to stringify the object I am passing? I dont think so right?
scheduleInterview.mutate({
employeeId,
startTime: dayjs(dateTime).toDate(),
});
scheduleInterview.mutate({
employeeId,
startTime: dayjs(dateTime).toDate(),
});
this is what it is
NeoBean
NeoBean16mo ago
could be caused by the Date() object
acronie
acronieOP16mo ago
coming from dayjs? How tho? I feel its that too but not really sure z dateTime is coming from datetime input @neobean
NeoBean
NeoBean16mo ago
well toDate() method returns an entire javascript Date() class
acronie
acronieOP16mo ago
Hmmm But how does it work in dev mode? I would surely see something
NeoBean
NeoBean16mo ago
idk honestly, but im curious
acronie
acronieOP16mo ago
export const ScheduleInterviewSchema = z.object({
employeeId: z.string().nonempty(),
startTime: z.date(),
});
export const ScheduleInterviewSchema = z.object({
employeeId: z.string().nonempty(),
startTime: z.date(),
});
using z.date which expects the whole date ig
NeoBean
NeoBean16mo ago
and you're using superjson too right?
acronie
acronieOP16mo ago
I assume yes Id need to check yes I am transformer: superjson,
NeoBean
NeoBean16mo ago
if its not for the date, it could be for anything, you need debug chunk by chunk ¯\_(ツ)_/¯
acronie
acronieOP16mo ago
this is the payload of the network request
No description
acronie
acronieOP16mo ago
{
"0": {
"json": {
"employeeId": "clm8uz2zd0000mc2hucjj3czl",
"startTime": "2023-09-07T15:22:00.000Z"
},
"meta": {
"values": {
"startTime": [
"Date"
]
}
}
}
}
{
"0": {
"json": {
"employeeId": "clm8uz2zd0000mc2hucjj3czl",
"startTime": "2023-09-07T15:22:00.000Z"
},
"meta": {
"values": {
"startTime": [
"Date"
]
}
}
}
}
whcih i think is valid date too idk whats causing the error then
NeoBean
NeoBean16mo ago
are you using errorFormatters / try catch anywhere that just throws BAD_REQUEST/INTERNAL_SERVER_ERROR but doesnt log or respond with a proper message/error data? also you using mongodb? if employeeId is supposed to be an objectId, its invalid have you tried running the production mode locally? is everything same for both dev/prod? like payload, database configuration/indexes etc
acronie
acronieOP16mo ago
no Works locally

Did you find this page helpful?