-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sentry & use vite env & add kakao oauth
- Loading branch information
Showing
27 changed files
with
1,644 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,7 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import useEnv from '@/hooks/useEnv'; | ||
|
||
const KakaoLoginButton: React.FC = () => { | ||
const env = useEnv(); | ||
const [kakaoAuthUrl, setKakaoAuthUrl] = useState(''); | ||
|
||
useEffect(() => { | ||
const redirectUri = | ||
window.location.origin.replace('localhost', '127.0.0.1') + '/oauth/kakao'; | ||
setKakaoAuthUrl( | ||
`${env.API_URL}/oauth2/authorization/kakao?redirect_to=${redirectUri}`, | ||
); | ||
// setKakaoAuthUrl('http://146.56.161.252:8080/oauth2/authorization/kakao'); | ||
}, [env.API_URL]); | ||
|
||
return ( | ||
<a href={kakaoAuthUrl}> | ||
<button>카카오로 로그인</button> | ||
</a> | ||
); | ||
}; | ||
const KakaoLoginButton: React.FC = () => ( | ||
<a href="/oauth/kakao"> | ||
<button>카카오로 로그인</button> | ||
</a> | ||
); | ||
|
||
export default KakaoLoginButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createContext } from 'react'; | ||
|
||
export interface AuthStore { | ||
isLoggedIn: boolean; | ||
} | ||
|
||
const AuthContext = createContext<AuthStore>({ | ||
isLoggedIn: false, | ||
}); | ||
|
||
export default AuthContext; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { RemixBrowser, useLocation, useMatches } from '@remix-run/react'; | ||
import * as Sentry from '@sentry/remix'; | ||
import { startTransition, StrictMode, useEffect } from 'react'; | ||
import { hydrateRoot } from 'react-dom/client'; | ||
|
||
Sentry.init({ | ||
dsn: import.meta.env.SHARED_SENTRY_DSN, | ||
tracesSampleRate: 1, | ||
|
||
integrations: [ | ||
Sentry.browserTracingIntegration({ | ||
useEffect, | ||
useLocation, | ||
useMatches, | ||
}), | ||
// https://github.com/import-js/eslint-plugin-import/issues/2969#issuecomment-1967510143 | ||
// eslint-disable-next-line import/namespace | ||
Sentry.replayIntegration({ | ||
maskAllText: true, | ||
blockAllMedia: true, | ||
}), | ||
], | ||
|
||
replaysSessionSampleRate: 0.1, | ||
replaysOnErrorSampleRate: 1, | ||
environment: import.meta.env.SHARED_APP_MODE, | ||
}); | ||
|
||
startTransition(() => { | ||
hydrateRoot( | ||
document, | ||
<StrictMode> | ||
<RemixBrowser /> | ||
</StrictMode>, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import type { | ||
AppLoadContext, | ||
EntryContext, | ||
HandleDataRequestFunction, | ||
} from '@remix-run/cloudflare'; | ||
import { RemixServer } from '@remix-run/react'; | ||
import * as Sentry from '@sentry/remix'; | ||
import * as isbotModule from 'isbot'; | ||
import { renderToReadableStream } from 'react-dom/server'; | ||
|
||
Sentry.init({ | ||
dsn: import.meta.env.SHARED_SENTRY_DSN, | ||
tracesSampleRate: 1, | ||
autoInstrumentRemix: true, | ||
environment: import.meta.env.SHARED_APP_MODE, | ||
}); | ||
|
||
export const handleError = Sentry.sentryHandleError; | ||
|
||
export default async function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext, | ||
loadContext: AppLoadContext, | ||
) { | ||
const body = await renderToReadableStream( | ||
<RemixServer context={remixContext} url={request.url} />, | ||
{ | ||
signal: request.signal, | ||
onError(error: unknown) { | ||
// Log streaming rendering errors from inside the shell | ||
console.error(error); | ||
responseStatusCode = 500; | ||
}, | ||
}, | ||
); | ||
|
||
if (isBotRequest(request.headers.get('user-agent'))) { | ||
await body.allReady; | ||
} | ||
|
||
responseHeaders.set('Content-Type', 'text/html'); | ||
|
||
const cookieHeader = await loadContext.authSessionService.commitSession(); | ||
if (cookieHeader) { | ||
responseHeaders.append('Set-Cookie', cookieHeader); | ||
} | ||
|
||
const response = new Response(body, { | ||
headers: responseHeaders, | ||
status: responseStatusCode, | ||
}); | ||
|
||
return response; | ||
} | ||
|
||
export const handleDataRequest: HandleDataRequestFunction = async ( | ||
response, | ||
{ context }, | ||
) => { | ||
const cookieHeader = await context.authSessionService.commitSession(); | ||
if (cookieHeader) { | ||
response.headers.append('Set-Cookie', cookieHeader); | ||
} | ||
return response; | ||
}; | ||
|
||
// We have some Remix apps in the wild already running with isbot@3 so we need | ||
// to maintain backwards compatibility even though we want new apps to use | ||
// isbot@4. That way, we can ship this as a minor Semver update to @remix-run/dev. | ||
function isBotRequest(userAgent: string | null) { | ||
if (!userAgent) { | ||
return false; | ||
} | ||
|
||
// isbot >= 3.8.0, >4 | ||
if ('isbot' in isbotModule && typeof isbotModule.isbot === 'function') { | ||
return isbotModule.isbot(userAgent); | ||
} | ||
|
||
// isbot < 3.8.0 | ||
if ('default' in isbotModule && typeof isbotModule.default === 'function') { | ||
return isbotModule.default(userAgent); | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useContext } from 'react'; | ||
import AuthContext from '@/contexts/AuthContext'; | ||
|
||
const useAuth = () => { | ||
const authStore = useContext(AuthContext); | ||
|
||
return authStore; | ||
}; | ||
|
||
export default useAuth; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
export const loader = async () => null; | ||
import { type LoaderFunctionArgs } from '@remix-run/cloudflare'; | ||
import { redirectWithAuthCookie } from '@/utils/server'; | ||
|
||
const KakaoRedirect = () => ( | ||
<div> | ||
{/* <p className={textStyle.headline1B}>{fetcher.state}</p> | ||
<fetcher.Form method="POST"> | ||
<button type="submit">test submit</button> | ||
</fetcher.Form> */} | ||
</div> | ||
); | ||
export const loader = async ({ request, context }: LoaderFunctionArgs) => { | ||
const url = new URL(request.url); | ||
const { origin } = url; | ||
|
||
export default KakaoRedirect; | ||
return redirectWithAuthCookie( | ||
`${import.meta.env.SERVER_API_URL}/oauth2/authorization/kakao?redirect_to=${origin}/oauth`, | ||
context.authSessionService, | ||
); | ||
}; |
Oops, something went wrong.