Next.js Discord

Discord Forum

API when using NextResponse.json, it cast number and Date fields to string when returning response

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I'm trying to preserve my field type after returning the api response but i don't seewhere i could configure this.
Using nextjs 15

1 Reply

Asian black bear
The default behavior is to serialize dates as string and is working as intended. Numbers on the other hand are serialized as numbers. If you're receiving strings then it's an issue on your end and you have to debug it.