Ahmed Eid
Ahmed Eid
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
removing "Content-Type": "application/json", from the headers fixed the issue.
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
No description
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
logging the req.body in trpc middleware logs {"0":{"json":{"phone":"123456789"}}}
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
input body is indeed an object.
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
No description
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
No description
22 replies
TtRPC
Created by xeon06 on 1/10/2023 in #❓-help
input needs to be an object when doing a batch call?
I'm facing this issue with nextjs and have no idea how to resolve it. any ideas ?
22 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
No description
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
import { httpBatchLink } from "@trpc/client"
import { createTRPCNext } from "@trpc/next"
import superjson from "superjson"

import { AppRouter } from "../../../apis/src/router"
import { getBaseUrl } from "./utils"
import { ENV } from "./env"

export const trpc = createTRPCNext<AppRouter>({
config(opts) {
const { ctx } = opts
return {
transformer: superjson, // optional - adds superjson serialization
links: [
httpBatchLink({
fetch(url, options) {
return fetch(url, {
...options,
credentials: "include",
})
},
// The server needs to know your app's full url
// url: `${getBaseUrl()}/api/trpc`,
url: ENV.BASE_URL,
headers() {
return {
...(typeof window === "undefined"
? {
...ctx?.req?.headers,
cookie: ctx?.req?.headers?.cookie,
}
: {}),
"Content-Type": "application/json",
accept: "application/json",
"accept-encoding": "gzip, deflate, br",
platform: "web",
}
},
}),
],
}
},
ssr: true,
}
import { httpBatchLink } from "@trpc/client"
import { createTRPCNext } from "@trpc/next"
import superjson from "superjson"

import { AppRouter } from "../../../apis/src/router"
import { getBaseUrl } from "./utils"
import { ENV } from "./env"

export const trpc = createTRPCNext<AppRouter>({
config(opts) {
const { ctx } = opts
return {
transformer: superjson, // optional - adds superjson serialization
links: [
httpBatchLink({
fetch(url, options) {
return fetch(url, {
...options,
credentials: "include",
})
},
// The server needs to know your app's full url
// url: `${getBaseUrl()}/api/trpc`,
url: ENV.BASE_URL,
headers() {
return {
...(typeof window === "undefined"
? {
...ctx?.req?.headers,
cookie: ctx?.req?.headers?.cookie,
}
: {}),
"Content-Type": "application/json",
accept: "application/json",
"accept-encoding": "gzip, deflate, br",
platform: "web",
}
},
}),
],
}
},
ssr: true,
}
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
so mainly I am setting cookies in my middleware like so.
response.cookies.set("lat", latParam)
response.cookies.set("lng", lngParam)
response.cookies.set("lat", latParam)
response.cookies.set("lng", lngParam)
I tried adding an origin, however it didn't work.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
I think if I am able to proxy those requests, then I could transform data to / from my service easily.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
yeah that's the main issue, I am not able to set / send cookies from frontend to my TRPC service.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
could you please explain what you mean, I have not CORS issues. the url is white listed on my TRPC service.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
when queries / mutations are ran on the client.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
I currently have my nextjs app calling TRPC API directly which is working fine, however I have been facing issues with cross site cookies.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
No description
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
yes exactly.
30 replies
TtRPC
Created by Poonda on 8/11/2024 in #❓-help
Forward NextJs Request to TRPC Server
wondering if you were able to solve this issue. @david I also have this case, the api was developed separately and is much older than our nextjs app.
30 replies
TtRPC
Created by Ahmed Eid on 2/14/2025 in #❓-help
Nextjs Proxy an exteral TRPC api via pages/api/trpc/[trpc].ts ?
both my nexjs app and api are inside a monorepo.
3 replies