5a. Session verification in an API call
note
This is applicable for when the frontend calls an API in the /pages/api
folder.
For this guide, we will assume that we want an API /api/user GET
which returns the current session information.
/pages/api/user.js
#
1) Create a new file - An example of this is here.
supertokens.init
function#
2) Call the Remember that whenever we want to use any functions from the supertokens-node
lib, we have to call the supertokens.init
function at the top of that serverless function file.
pages/api/user.ts
import supertokens from 'supertokens-node'import { backendConfig } from '../../../config/backendConfig'
supertokens.init(backendConfig())
verifySession
session function#
3) Call the Please fill the form below to see the code snippet (* = Required)
To learn more about what these properties mean read here.
Website Domain:*

This is the URL of your website.