fix: redirect url for github apps (#280)

pull/281/head
David Flanagan 2023-11-28 21:27:04 +00:00 committed by GitHub
parent cfaa80a9e7
commit 14443cc255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/oauth-providers': patch
---
ensure redirect to original URL for GitHub apps

View File

@ -40,7 +40,11 @@ export function githubAuth(options: {
path: '/',
// secure: true,
})
return c.redirect(auth.redirect())
// OAuth apps can't have multiple callback URLs, but GitHub Apps can.
// As such, we want to make sure we call back to the same location
// for GitHub apps and not the first configured callbackURL in the app config.
return c.redirect(auth.redirect().concat(options.oauthApp ? '' : `&redirect_uri=${c.req.url}`))
}
// Retrieve user data from github