File tree Expand file tree Collapse file tree
packages/user/src/supertokens Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,12 @@ import { verifySession } from "supertokens-node/recipe/session/framework/fastify
1010
1111import init from "./init" ;
1212
13- import type { FastifyError , FastifyInstance } from "fastify" ;
13+ import type {
14+ FastifyError ,
15+ FastifyInstance ,
16+ FastifyReply ,
17+ FastifyRequest ,
18+ } from "fastify" ;
1419
1520const plugin = async ( fastify : FastifyInstance ) => {
1621 const { config, log } = fastify ;
@@ -19,16 +24,16 @@ const plugin = async (fastify: FastifyInstance) => {
1924
2025 init ( fastify ) ;
2126
22- // Explicitly cast the errorHandler to the correct type
23- // [RL 2025-04-01] This should be fixed when supertokens-node is updated
24- fastify . setErrorHandler (
25- errorHandler ( ) as unknown as (
26- this : FastifyInstance ,
27- error : FastifyError ,
28- request : import ( "fastify" ) . FastifyRequest ,
29- reply : import ( "fastify" ) . FastifyReply ,
30- ) => void ,
31- ) ;
27+ if ( config . user . supertokens . setErrorHandler !== false ) {
28+ fastify . setErrorHandler (
29+ errorHandler ( ) as unknown as (
30+ this : FastifyInstance ,
31+ error : FastifyError ,
32+ request : FastifyRequest ,
33+ reply : FastifyReply ,
34+ ) => void ,
35+ ) ;
36+ }
3237
3338 await fastify . register ( cors , {
3439 origin : config . appOrigin ,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ interface SupertokensConfig {
4747 resetPasswordPath ?: string ;
4848 emailVerificationPath ?: string ;
4949 sendUserAlreadyExistsWarning ?: boolean ;
50+ setErrorHandler ?: boolean ;
5051}
5152
5253export type { SupertokensConfig , SupertokensRecipes } ;
You can’t perform that action at this time.
0 commit comments