-
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: use cloudflare env only & modify dev proxy plugin
- Loading branch information
Showing
21 changed files
with
627 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createContext } from 'react'; | ||
import { type ClientEnv } from '@server/constants/env'; | ||
|
||
export const EnvContext = createContext<ClientEnv | null>(null); |
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,21 @@ | ||
import { useContext } from 'react'; | ||
import { EnvContext } from '@/contexts/EnvContext'; | ||
import { type ClientEnv, clientEnvSchema } from '@server/constants/env'; | ||
|
||
/** | ||
* 클라이언트용 환경 변수를 얻는 hook | ||
* @example | ||
* ``` | ||
* const env = useEnv(); | ||
* console.log(env.KAKAO_CLIENT_ID); | ||
* ``` | ||
*/ | ||
const useEnv = (): ClientEnv => { | ||
const envFromContext = useContext(EnvContext); | ||
|
||
const env = clientEnvSchema.parse(envFromContext); | ||
|
||
return env; | ||
}; | ||
|
||
export default useEnv; |
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,31 +1,42 @@ | ||
import { json, type LoaderFunctionArgs } from '@remix-run/cloudflare'; | ||
import { | ||
Links, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration, | ||
useLoaderData, | ||
} from '@remix-run/react'; | ||
import { type ReactNode } from 'react'; | ||
import { EnvContext } from '@/contexts/EnvContext'; | ||
|
||
import './root.css'; | ||
import '@/styles/theme.css'; | ||
|
||
export const Layout = ({ children }: { children: ReactNode }) => ( | ||
<html lang="ko"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
{children} | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
export const loader = async (args: LoaderFunctionArgs) => | ||
json({ | ||
env: args.context.clientEnv, | ||
}); | ||
|
||
const App = () => <Outlet />; | ||
const App = () => { | ||
const data = useLoaderData<typeof loader>(); | ||
|
||
return ( | ||
<html lang="ko"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<EnvContext.Provider value={data.env}> | ||
<Outlet /> | ||
</EnvContext.Provider> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
}; | ||
|
||
export default App; |
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,15 @@ | ||
import { type LoaderFunctionArgs } from '@remix-run/cloudflare'; | ||
|
||
export const loader = async ({ request }: LoaderFunctionArgs) => { | ||
const url = new URL(request.url); | ||
const code = url.searchParams.get('code'); | ||
const state = url.searchParams.get('state'); | ||
|
||
console.log(code, state); | ||
|
||
return null; | ||
}; | ||
|
||
const KakaoRedirect = () => <div>카카오 로그인 중...</div>; | ||
|
||
export default KakaoRedirect; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.