From 3c37d5500df1c1b671784fd5793bbc71082962f4 Mon Sep 17 00:00:00 2001 From: Emma Hamilton Date: Thu, 28 Nov 2024 10:11:58 +1000 Subject: [PATCH] Return more useful error when reaching `/api/keystatic/github/created-app` route when the GitHub App is already setup --- .changeset/sour-ravens-know.md | 5 +++++ packages/keystatic/src/api/generic.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/sour-ravens-know.md diff --git a/.changeset/sour-ravens-know.md b/.changeset/sour-ravens-know.md new file mode 100644 index 000000000..3c8b8527a --- /dev/null +++ b/.changeset/sour-ravens-know.md @@ -0,0 +1,5 @@ +--- +'@keystatic/core': patch +--- + +Return more useful error when reaching `/api/keystatic/github/created-app` route when the GitHub App is already setup diff --git a/packages/keystatic/src/api/generic.ts b/packages/keystatic/src/api/generic.ts index af0c9af66..f74d5e810 100644 --- a/packages/keystatic/src/api/generic.ts +++ b/packages/keystatic/src/api/generic.ts @@ -177,6 +177,12 @@ export function makeGenericAPIRouteHandler( ['Set-Cookie', immediatelyExpiringCookie('keystatic-gh-refresh-token')], ]); } + if (joined === 'github/created-app') { + return { + status: 404, + body: 'It looks like you just tried to create a GitHub App for Keystatic but there is already a GitHub App configured for Keystatic.\n\nYou may be here because you started creating a GitHub App but then started the process again elsewhere and completed it there. You should likely go back to Keystatic and sign in with GitHub to continue.', + }; + } return { status: 404, body: 'Not Found' }; }; }