ironGym/webapp/src/middleware/validateAuthToken.ts
2025-06-26 23:29:47 +03:00

14 lines
555 B
TypeScript

/**
*
* @description this file contain the @validateAuthToken function that be used inside the middleware.ts
* * source : https://mongoosejs.com/docs/6.x/docs/typescript.html
*/
export default async function validateAuthToken(authToken : string | undefined) : Promise<boolean | undefined>
{
console.log("----------NEXT_PUBLIC_API_BASE : " , process.env.NEXT_PUBLIC_API_BASE)
let data : {
success : boolean,
} = await (await fetch(process.env.NEXT_PUBLIC_API_BASE+"/api/auth?authToken="+authToken)).json()
return data.success
}