.gidgiddoni
08/22/2022, 3:48 PMpages/api/user.js
file it has the following code:
supertokens.init(backendConfig())
export default async function user(req, res) {
await superTokensNextWrapper(
async (next) => {
return await verifySession()(req, res, next)
},
req,
res
)
return res.json({
note: "Fetch any data from your application for authenticated user after using verifySession middleware",
userId: req.session.getUserId(),
sessionHandle: req.session.getHandle(),
accessTokenPayload: req.session.getAccessTokenPayload(),
});
}
The part where it checks calls verifySession
I would like to move into a middleware that is called for every api in the /api/*
file path. I thought I could just move that verifySession call into a another function and nextjs handles when it is invoked, but I'm not having much luck. Is there a way to do with with Supertokens or does the verify session need to be called directly in every api route?rp_st
08/22/2022, 3:54 PM.gidgiddoni
08/22/2022, 3:55 PMrp_st
08/22/2022, 3:56 PMrp_st
08/22/2022, 3:56 PM.gidgiddoni
08/22/2022, 4:00 PM.gidgiddoni
08/22/2022, 4:00 PMrp_st
08/22/2022, 4:01 PM