Skip to content

Commit

Permalink
Onboarding: Guard deployedURL
Browse files Browse the repository at this point in the history
Before, it was possible to provide `https://foo.com/` as input and generate a redirect_uri like `https://foo.com//api/keystatic/github/oauth/callback` which triggers the "The `redirect_uri` is not associated with this application." error by Github. Now the path is merged with the URL correctly for any valid URL input.
  • Loading branch information
tordans committed Dec 6, 2024
1 parent e65e7f3 commit 88bcf5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-parrots-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystatic/core': patch
---

During onboarding, make sure the Deployed App URL does not have double slashes.
9 changes: 7 additions & 2 deletions packages/keystatic/src/app/onboarding/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,20 @@ export function KeystaticSetup(props: { config: GitHubConfig }) {
parseRepoConfig(props.config.storage.repo).owner
} Keystatic`,
url: deployedURL
? `${deployedURL}/keystatic`
? new URL('/keystatic', deployedURL).toString()
: `${window.location.origin}/keystatic`,
public: true,
redirect_url: `${window.location.origin}/api/keystatic/github/created-app`,
callback_urls: [
`${window.location.origin}/api/keystatic/github/oauth/callback`,
`http://127.0.0.1/api/keystatic/github/oauth/callback`,
...(deployedURL
? [`${deployedURL}/api/keystatic/github/oauth/callback`]
? [
new URL(
'/api/keystatic/github/oauth/callback',
deployedURL
).toString(),
]
: []),
],
request_oauth_on_install: true,
Expand Down

0 comments on commit 88bcf5d

Please sign in to comment.