Skip to content

Commit

Permalink
Merge pull request #68 from YAPP-Github/dev
Browse files Browse the repository at this point in the history
먹팟 v0.1 - 로그인 버그 수정
  • Loading branch information
sxungchxn authored Jul 2, 2023
2 parents ffb8d81 + d422d7c commit 485c9c1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
17 changes: 13 additions & 4 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ const nextConfig = {
// 프록시 설정
async rewrites(){
const API_ENDPOINT = process.env.API_URL ?? process.env.NEXT_PUBLIC_API_URL;
return process.env.NODE_ENV === 'development' ? [

const rewriteTargets = [
{
source: '/api/login',
destination: `${API_ENDPOINT}/v1/users/login`
},
]

if(process.env.NODE_ENV === 'development') {
rewriteTargets.push({
source: '/api/:path*',
destination: `${API_ENDPOINT}/:path*`,
}
] : [];

});
}

return rewriteTargets;
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/api/user/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { request } from '@/utils/ky/request';
class UserAPI {
/** 로그인한 유저의 프로필을 조회합니다 */
async getProfile() {
return request.get('v1/users/profile').json<Profile | undefined>();
return request
.get('v1/users/profile', {
cache: 'no-store',
})
.json<Profile | undefined>();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/login/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { LoginRequest, LoginResponse } from '../types/login';

export const postLogin = async ({ email, password, keep }: LoginRequest): Promise<LoginResponse> => {
const result = await request
.post('v1/users/login', {
.post('/api/login', {
prefixUrl: '',
json: {
email,
password,
Expand Down
3 changes: 2 additions & 1 deletion src/app/login/hooks/useLogin/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const useLogin = (): UseMutationResult<LoginResponse, unknown, LoginReque
return error;
};

const loginMutation = useMutation<LoginResponse, unknown, LoginRequest>(postLogin, {
const loginMutation = useMutation<LoginResponse, unknown, LoginRequest>({
mutationFn: postLogin,
onSuccess: handleLoginSuccess,
onError: handleLoginError,
});
Expand Down

0 comments on commit 485c9c1

Please sign in to comment.