Skip to content

Commit

Permalink
[fix] GitHub OAuth 2 sign-in page should not be proxied (fix #6)
Browse files Browse the repository at this point in the history
[fix] reading HTTP Error of KoAJAX
  • Loading branch information
TechQuery committed Aug 21, 2024
1 parent 0fe6b29 commit d83924b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-ssr-middleware",
"version": "0.8.3",
"version": "0.8.5",
"license": "LGPL-3.0-or-later",
"author": "[email protected]",
"description": "Koa-like middlewares for Next.js Server Side Rendering",
Expand Down
7 changes: 4 additions & 3 deletions source/middleware/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export async function errorLogger<
} catch (error) {
console.error(error);

const { status } = (error as HTTPError).response;

if (status === 404) return { notFound: true, props: {} as O };
if (error instanceof HTTPError) {
const { status } = error.response;

if (status === 404) return { notFound: true, props: {} as O };
}
throw error;
}
}
Expand Down
15 changes: 6 additions & 9 deletions source/middleware/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ export function githubOAuth2<I extends DataObject, O extends DataObject = {}>({
}: GitHubOAuthOption) {
return oauth2Signer<I, O>({
signInURL: redirect_uri =>
new URL(
`login/oauth/authorize?${buildURLData({
client_id,
scope: scopes?.join(' '),
allow_signup,
redirect_uri
})}`,
rootBaseURL
) + '',
`https://github.com/login/oauth/authorize?${buildURLData({
client_id,
scope: scopes?.join(' '),
allow_signup,
redirect_uri
})}`,
accessToken: async ({ code }) => {
const response = await fetch(
new URL('login/oauth/access_token', rootBaseURL),
Expand Down

0 comments on commit d83924b

Please sign in to comment.