Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update environment variables in turbo.json for GitHub OAuth and enhan…
…ce error handling in GitHub route. Improve clarity by defining specific error messages for missing client ID and secret.
  • Loading branch information
mdroidian committed Jun 16, 2025
commit 226ab8a5f74b9a78a203b9a6b63a4ca5fa96c7a0
16 changes: 10 additions & 6 deletions apps/website/app/api/oauth/github/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const CLIENT_SECRET =
process.env.NODE_ENV === "production"
? process.env.GH_CLIENT_SECRET_PROD
: process.env.GH_CLIENT_SECRET_DEV;

const REDIRECT_URI =
process.env.NODE_ENV === "production"
? "https://discourse-graph-git-roam-github-sync-discourse-graphs.vercel.app/auth/github"
Expand All @@ -18,13 +19,16 @@ export const POST = async (request: Request) => {
const { code } = await request.json();

if (!code) {
return NextResponse.json({ error: "Missing code" }, { status: 400 });
const error = "Missing code";
return NextResponse.json({ error }, { status: 400 });
}
if (!CLIENT_ID || !CLIENT_SECRET) {
return NextResponse.json(
{ error: "Missing client ID or secret" },
{ status: 400 },
);
if (!CLIENT_ID) {
const error = "Missing client ID";
return NextResponse.json({ error }, { status: 400 });
}
if (!CLIENT_SECRET) {
const error = "Missing client secret";
return NextResponse.json({ error }, { status: 400 });
}

try {
Expand Down
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"GEMINI_API_KEY",
"NODE_ENV",
"BLOB_READ_WRITE_TOKEN",
"GH_CLIENT_ID_PROD",
"GH_CLIENT_ID_DEV",
"GH_CLIENT_SECRET_PROD",
"GH_CLIENT_SECRET_DEV"
],
Expand All @@ -34,6 +36,8 @@
"OPENAI_API_KEY",
"ANTHROPIC_API_KEY",
"GEMINI_API_KEY",
"GH_CLIENT_ID_PROD",
"GH_CLIENT_ID_DEV",
"GH_CLIENT_SECRET_PROD",
"GH_CLIENT_SECRET_DEV"
],
Expand Down