forked from NotNet/gluestick
25 lines
716 B
TypeScript
25 lines
716 B
TypeScript
import { discordRedirectUri } from "../oauth";
|
|
|
|
export async function GET(request: Request) {
|
|
let url = `https://discord.com/oauth2/authorize`;
|
|
|
|
let randomAssString = Math.random().toString(36).substring(2, 15);
|
|
|
|
let params = new URLSearchParams();
|
|
params.set("response_type", "code");
|
|
params.set("client_id", process.env.DISCORD_CLIENT_ID);
|
|
params.set("scope", "guilds identify email");
|
|
params.set("state", randomAssString);
|
|
params.set("redirect_uri", discordRedirectUri());
|
|
params.set("prompt", "consent");
|
|
|
|
url += "?" + params.toString();
|
|
|
|
return new Response(null, {
|
|
status: 302,
|
|
headers: {
|
|
Location: url,
|
|
"Set-Cookie": `state=${randomAssString}; Path=/;`
|
|
}
|
|
});
|
|
}
|