File size: 526 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { withApiAuthRequired, getSession } from "@auth0/nextjs-auth0";

// Serverless function
// Protected API, requests to '/api/protected-api' without a valid session cookie will fail

async function handle(req, res) {
  const { user } = await getSession(req, res);

  try {
    res.status(200).json({
      session: "true",
      id: user.sub,
      nickname: user.nickname,
    });
  } catch (e) {
    res.status(500).json({ error: "Unable to fetch", description: e });
  }
}

export default withApiAuthRequired(handle);