Skip to content

Commit

Permalink
chore(example): add pages api route tokens handler
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogrodzki committed Sep 19, 2023
1 parent b0acd88 commit 52e233f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/next13-typescript-starter/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
17 changes: 17 additions & 0 deletions examples/next13-typescript-starter/pages/api/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { getTokensFromObject } from 'next-firebase-auth-edge/lib/next/tokens';
import { authConfig } from '../../config/server-config';

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const tokens = await getTokensFromObject(req.cookies, {
apiKey: authConfig.apiKey,
cookieName: authConfig.cookieName,
cookieSignatureKeys: authConfig.cookieSignatureKeys,
serviceAccount: authConfig.serviceAccount,
});

return res.status(200).json({ tokens });
}

0 comments on commit 52e233f

Please sign in to comment.