Describe the feature
Firebase functions (v2) provide an onRequest function which is a thin wrapper around an Express endpoint. Unfortunately, the wrapper appears to consume the request before it hits user space and so it is incompatible with the oRPC Express adapter.
Example of Ideal (an example of what works with tRPC):
export const api = onRequest((req, res) => {
req.url = req.url.replace("/api", "");
return createHTTPHandler({
router: appRouter,
createContext,
})(req, res);
});
What the docs currently suggest:
import { RPCHandler } from "@orpc/server/node";
import { onRequest } from "firebase-functions/v2/https";
import { createContext } from "./context.js";
import { router } from "./router.js";
const handler = new RPCHandler(router);
export const api = onRequest(async (req, res) => {
await handler.handle(req, res, {
prefix: "/api",
context: await createContext(req),
});
});
However, with this suggestion, the input is always undefined, though the route is matched correctly and no error is thrown (except for a validation error on the input if one exists of course).
Additional information
Describe the feature
Firebase functions (v2) provide an
onRequestfunction which is a thin wrapper around an Express endpoint. Unfortunately, the wrapper appears to consume the request before it hits user space and so it is incompatible with the oRPC Express adapter.Example of Ideal (an example of what works with tRPC):
What the docs currently suggest:
However, with this suggestion, the input is always undefined, though the route is matched correctly and no error is thrown (except for a validation error on the input if one exists of course).
Additional information