diff --git a/src/api/oauth/index.ts b/src/api/oauth/index.ts index 18f3f41..c4a25ce 100644 --- a/src/api/oauth/index.ts +++ b/src/api/oauth/index.ts @@ -1,5 +1,8 @@ -export const postOauthToken = async (code: string): Promise => { - const response = await fetch('/api/oauth/token', { +import ApiResponse from '@/types/api-response'; + +export const postOauthToken = async (code: string | null): Promise => { + const baseUrl = typeof window === 'undefined' ? process.env.NEXT_PUBLIC_BASE_URL : 'api'; + const response = await fetch(`${baseUrl}/oauth/token`, { method: 'POST', body: JSON.stringify({ code }), headers: { diff --git a/src/types/api-response.d.ts b/src/types/api-response.d.ts index 90a113d..499d6f3 100644 --- a/src/types/api-response.d.ts +++ b/src/types/api-response.d.ts @@ -9,7 +9,7 @@ declare namespace ApiResponse { result: string; } - interface ResponseAuthTokenData { + interface ResponseAuthTokenData extends ResponseResult { data: User; } }