Issue
- Some queries and mutations now produce
Unexpected end of JSON input
orUnterminated string in JSON at position
errors - This started happening after rebuilding with an unrelated update. It works locally, but not on the host.
Stack (Turborepo)
- api (Next.js v13.4.13)
- page/api/trpc/[trpc].ts
- client (Next.js v13.4.13)
- Connects to api using rewrites in next.config.ts
- trpc
- routers
- ...
- infra: render.com
- orm: prisma
Code
// apps/api/pages/api/trpc/[trpc].ts
export default createNextApiHandler({
router: appRouter,
createContext: createTRPCContext,
});
// apps/client/next.config.ts
async rewrites() {
return [
{
source: "/api/trpc/:path*",
destination: `${process.env.NEXT_PUBLIC_API}/api/trpc/:path*`,
},
];
},
Reponse Sample
// status: 200 GET
[
{
"result": {
"data": {
"json": [
{
"items": [
{
"id": "uuid",
"label": "label",
"status": "statusA",
"history": [
{
"creatorA // => creatorAccount
// status: 200 POST
[
{
"result": {
"data": {
"json": {
"ok": true
},
"meta": {
"v
What I've tried
- Directly connecting to the api with ThunderClient, etc.
- No change => It seems not to be a client-side configuration mistake
- Setting response headers
- Fixing Content-Type and Content-Encoding didn't make any difference
- Fixing versions of npm modules
- No change
Ensuring all queries/mutations work as before