Skip to content

Instantly share code, notes, and snippets.

@schiemon
Last active October 18, 2021 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schiemon/260b0f51f8e3564d4ace88b97fcdc602 to your computer and use it in GitHub Desktop.
Save schiemon/260b0f51f8e3564d4ace88b97fcdc602 to your computer and use it in GitHub Desktop.
import { NextApiRequest, NextApiResponse } from "next";
import { withApiAuthRequired } from "@auth0/nextjs-auth0";
import nc from "next-connect";
// Secured api endpoint.
// Possible synergy between next-connect and withApiAuthRequired from nextjs-auth0.
const handler = withApiAuthRequired(
nc<NextApiRequest, NextApiResponse>()
.get(
(req: NextApiRequest, res: NextApiResponse) => {
// ...
}
)
.post(
(req: NextApiRequest, res: NextApiResponse) => {
// ...
}
)
);
export default handler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment