oscarama
oscarama
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
issue is fixed by the way, some obscure issue with nginx (or I'm just ignorant lol). thanks for your help
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
perhaps. I'll try that, thanks
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
got it
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
is all I get in the logs
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
yeah, I'm using pm2 in this case
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
TRPCClientError: fetch failed
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
idk if any of that has any bearing
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
and I'm using nginx
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
and if I dont use 127.0.0.1 I get a 500 Fetch Failed error with no extra message
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
mind you it does work locally, but when I put it on the VPS I get the cors error
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
const handleTRPC: Handle = async ({ event, resolve }) => {
if (event.request.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
},
});
};

if (event.url.pathname.startsWith(`${trpcPathBase}/`)) {
const response = await fetchRequestHandler({
endpoint: trpcPathBase,
req: event.request,
router: appRouter,
createContext: () => {
return createContext(event);
},
});

response.headers.append("Access-Control-Allow-Origin", "*");

return response;
};

// eslint-disable-next-line no-return-await
return await resolve(event);
};
const handleTRPC: Handle = async ({ event, resolve }) => {
if (event.request.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
},
});
};

if (event.url.pathname.startsWith(`${trpcPathBase}/`)) {
const response = await fetchRequestHandler({
endpoint: trpcPathBase,
req: event.request,
router: appRouter,
createContext: () => {
return createContext(event);
},
});

response.headers.append("Access-Control-Allow-Origin", "*");

return response;
};

// eslint-disable-next-line no-return-await
return await resolve(event);
};
with svelte I have this
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
might it be a sveltekit issue?
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
it's all in one repo with sveltekit and sveltekit is using adapter-node
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
// public.ts
import type { ContextType } from "./context";
import { initTRPC } from "@trpc/server";

const t = initTRPC.context<ContextType>().create();

export const middleware = t.middleware;
export const router = t.router;
// public.ts
import type { ContextType } from "./context";
import { initTRPC } from "@trpc/server";

const t = initTRPC.context<ContextType>().create();

export const middleware = t.middleware;
export const router = t.router;
29 replies
TtRPC
Created by oscarama on 5/29/2023 in #❓-help
trpc cors
I'm not using any adapter
29 replies
TtRPC
Created by oscarama on 12/12/2022 in #❓-help
cookies, headers and authentication
arrived right on time
13 replies
TtRPC
Created by oscarama on 12/12/2022 in #❓-help
cookies, headers and authentication
13 replies
TtRPC
Created by oscarama on 12/12/2022 in #❓-help
cookies, headers and authentication
a bit annoying to do in the +page.server.ts but works 🤷‍♂️
13 replies
TtRPC
Created by oscarama on 12/12/2022 in #❓-help
cookies, headers and authentication
that helps, thank you
13 replies