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
miho
miho15mo ago
@Vinny (@Wasp) I think we solved it in our SaaSGPT template for Stripe payloads?
Vinny (@Wasp)
Vinny (@Wasp)15mo ago
@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
miho
miho15mo ago
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 parser
Configuring 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.
simplestake
simplestake15mo ago
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…”?
shayne
shayne15mo ago
Yup that should do it @miho thnx
simplestake
simplestake15mo ago
@shayne
miho
miho15mo ago
Not right now 😬 it's part of the auth process templates We are working on better customisation this quarter 😊
Want results from more Discord servers?
Add your server