diff --git a/packages/app/server/routes/check.post.ts b/packages/app/server/routes/check.post.ts index dbbe8146..8a900b05 100644 --- a/packages/app/server/routes/check.post.ts +++ b/packages/app/server/routes/check.post.ts @@ -17,18 +17,28 @@ export default eventHandler(async (event) => { authenticated = true; } catch {} - try { - await app.octokit.request("GET /orgs/{org}/installation", { - org: owner, - }); - authenticated = true; - } catch {} + if (!authenticated) { + try { + const { data: installation } = await app.octokit.request( + "GET /orgs/{org}/installation", + { org: owner }, + ); + const installationOctokit = await app.getInstallationOctokit( + installation.id, + ); + await installationOctokit.request("GET /repos/{owner}/{repo}", { + owner, + repo, + }); + authenticated = true; + } catch {} + } if (!authenticated) { throw createError({ statusCode: 404, fatal: true, - message: `The app https://github.com/apps/pkg-pr-new is not installed on ${owner}/${repo}.`, + message: `The app https://github.com/apps/pkg-pr-new is not installed on or does not have access to ${owner}/${repo}.`, }); }