icns-frontend/pages/api/auth/index.ts
2022-11-30 18:58:19 +09:00

16 lines
511 B
TypeScript

import type { NextApiRequest, NextApiResponse } from "next";
import { authClient } from "../../client/twitter";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
if (!process.env.STATE || !process.env.CODE_CHALLENGE) {
return res.status(500).send("No state or code_challenge");
}
const authUrl = authClient.generateAuthURL({
state: process.env.STATE,
code_challenge: process.env.CODE_CHALLENGE,
code_challenge_method: "plain",
});
res.redirect(authUrl);
}