zrilman
zrilman
TtRPC
Created by zrilman on 6/8/2023 in #❓-help
VS Code becomes unresponsive
Sadly no. I still have no idea what's causing the issue. But I haven't worked on that project since June. Maybe upgrading trpc would fix the issue, but I can't guarantee
8 replies
TtRPC
Created by zrilman on 6/8/2023 in #❓-help
VS Code becomes unresponsive
I've tried, but the issue remains :/
8 replies
TtRPC
Created by zrilman on 6/3/2023 in #❓-help
How to force SSL on projects using tRPC?
Basically I've tried to use the code from https://www.npmjs.com/package/express-sslify package By adding a middleware to my procedures, but that resulted in ,dns_probe_finished_nxdomain error on production. Then I found this article on tRPC website https://trpc.io/docs/server/adapters/nextjs And I've tried to write a custom handler that uses similar logic from the above-mentioned package. But the same error occurred 😔 Code snippet:
type Environment = "production" | "development" | "other";

// @see https://nextjs.org/docs/api-routes/introduction
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const currentEnv = process.env.NODE_ENV as Environment;

const host = req?.headers?.["host"] ?? "";
const forwaredProto = req?.headers?.["x-forwarded-proto"] ?? "";
const local = req.url ?? "";
const schema = forwaredProto.indexOf("https") !== -1 ? "https" : "http";
const www = host.replace(/www\./gi, "");
const fullUrl = `https://${www}${local}`;
const removeSlash = (site: string) => site.replace(/\/$/, "");
console.log("👉 file: [trpc].ts:69 handler fullUrl:", fullUrl);

const notLocalHost = !www?.includes("localhost");

if (notLocalHost) {
if (schema !== "https") {
return res.redirect(removeSlash(fullUrl));
}
if (/^www\./i.test(host) && schema === "https") {
return res.redirect(removeSlash(fullUrl));
}
if (/\/$/.test(fullUrl) && fullUrl !== `https://${www}/`) {
return res.redirect(removeSlash(fullUrl));
}
}

// finally pass the request on to the tRPC handler
return apiHandler(req, res);
}
type Environment = "production" | "development" | "other";

// @see https://nextjs.org/docs/api-routes/introduction
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const currentEnv = process.env.NODE_ENV as Environment;

const host = req?.headers?.["host"] ?? "";
const forwaredProto = req?.headers?.["x-forwarded-proto"] ?? "";
const local = req.url ?? "";
const schema = forwaredProto.indexOf("https") !== -1 ? "https" : "http";
const www = host.replace(/www\./gi, "");
const fullUrl = `https://${www}${local}`;
const removeSlash = (site: string) => site.replace(/\/$/, "");
console.log("👉 file: [trpc].ts:69 handler fullUrl:", fullUrl);

const notLocalHost = !www?.includes("localhost");

if (notLocalHost) {
if (schema !== "https") {
return res.redirect(removeSlash(fullUrl));
}
if (/^www\./i.test(host) && schema === "https") {
return res.redirect(removeSlash(fullUrl));
}
if (/\/$/.test(fullUrl) && fullUrl !== `https://${www}/`) {
return res.redirect(removeSlash(fullUrl));
}
}

// finally pass the request on to the tRPC handler
return apiHandler(req, res);
}
5 replies
TtRPC
Created by zrilman on 6/3/2023 in #❓-help
How to force SSL on projects using tRPC?
Hey. I'm hosting my project on Heroku
5 replies
TtRPC
Created by zrilman on 2/28/2023 in #❓-help
Using tRPC in CRON jobs
Yes. Exactly. Since Vercel allows ts & js cron jobs a simple vanilla client should do the work? https://trpc.io/docs/vanilla
4 replies
TtRPC
Created by zrilman on 2/18/2023 in #❓-help
Input is too big for a single dispatch
Yes. It's a query. I've ended up with switching to mutation 😄
7 replies