Class BodyUsedError

Whenever you try to call authenticator.authenticate("form", request) and the request's body was already read before, the FormStrategy will throw this error.

To fix it, ensure that you either move the logic that depends on the body to inside the strategy's verify callback, or clone the request before reading.

let formData = await request.clone().formData()
// do something with formData
let user = await authenticator.authenticate("form", request);
authenticator.use(
new FormStrategy(async ({ form }) => {
// do something with form here
}),
"login",
);

Hierarchy

Constructors

Properties

cause?: unknown
message: string
name: string = "BodyUsedError"
stack?: string
prepareStackTrace?: ((err: Error, stackTraces: CallSite[]) => any)

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void