silverwolf-x/project / examples /auth0 /pages /api /protected-api.ts
silverwolf-x's picture
download
raw
526 Bytes
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);

Xet Storage Details

Size:
526 Bytes
·
Xet hash:
60aefde414175b1c69b1b96711b3ed47334affe07594267ac8a0d28b2d5eeb9f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.