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' }; }; }