export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);
context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});
const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}
export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);
context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});
const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}