T
tRPC

tRPC Call To Server

tRPC Call To Server

VVengeance1/30/2023
On the mobile version of my app, in NextJS, the build has to be static so I have to use my hosted web version ass the server url, but when it makes requests it says stuff like no query procedure found, whereas in the web version the request works just fine, I think it's because the static version of the app doesn't request with any cookies. How can I solve this? https://trpc.io/docs/cors me when i dont read docs: 🧍‍♂️
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Request-Method", "*");
res.setHeader("Access-Control-Allow-Methods", "OPTIONS, GET");
res.setHeader("Access-Control-Allow-Headers", "*");
if (req.method === "OPTIONS") {
res.writeHead(200);
return res.end();
}

return nextApiHandler(req, res);
}
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Request-Method", "*");
res.setHeader("Access-Control-Allow-Methods", "OPTIONS, GET");
res.setHeader("Access-Control-Allow-Headers", "*");
if (req.method === "OPTIONS") {
res.writeHead(200);
return res.end();
}

return nextApiHandler(req, res);
}
still getting response body is not available to scripts (Reason: CORS No Allow Credentials) 😔 found the answer here https://canary.discord.com/channels/867764511159091230/1067565106080264232/1067743471554809897

Looking for more? Join the community!

T
tRPC

tRPC Call To Server

Join Server