rawBody through apiNamespace
import express from "express";
import { MiddlewareConfigFn } from "@wasp/middleware";
import bodyParser from "body-parser";
interface CustomRequest extends express.Request {
rawBody?: Buffer;
}
const PayMiddleware: express.RequestHandler = bodyParser.json({
verify: (req: CustomRequest, res, buf) => {
req.rawBody = buf;
},
});
export const rawBodyNamespaceMiddlewareFn: MiddlewareConfigFn = (
middlewareConfig
) => {
middlewareConfig.set("context", PayMiddleware);
return middlewareConfig;
};
I haven't found a way to get a request's raw body. It seems wasp's preceding middleware conflicts.
7 Replies
@Vinny (@Wasp) I think we solved it in our SaaSGPT template for Stripe payloads?
@shayne mentioned how to solve it but I never got around to it. You have to put the raw body parser as the first middelware in express. In this example it gets set at the end, I suppose
Look at this example in the docs: https://wasp-lang.dev/docs/advanced/middleware-config#2-customize-api-specific-middleware
Removes
json
and addsraw
body parserConfiguring Middleware | Wasp
Wasp comes with a minimal set of useful Express middleware in every application. While this is good for most users, we realize some may wish to add, modify, or remove some of these choices both globally, or on a per-api/path basis.
Awesome, thanks that worked! @miho
@miho is there any way to remove the strings that sometimes appear when a page loads? Such as “Loading …” or “Completing log in process…”?
Yup that should do it @miho thnx
@shayne
Not right now 😬 it's part of the auth process templates
We are working on better customisation this quarter 😊