Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions src/hooks/use-auth/use-auth-login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export const useLogin = () => {
const [loginError, setLoginError] = useState<string | null>(null);
const clearLoginError = useCallback(() => setLoginError(null), []);

const { setIsAuthenticated: _ } = useAuth();
const { setIsAuthenticated } = useAuth();

const handleLogin = async (payload: LoginRequest, _formApi: { reset: () => void }) => {
const handleLogin = async (payload: LoginRequest, formApi: { reset: () => void }) => {
setLoginError(null);

try {
Expand All @@ -70,27 +70,12 @@ export const useLogin = () => {
secure: process.env.NODE_ENV === 'production',
});

// formApi.reset();
formApi.reset();

// setIsAuthenticated(true);
setIsAuthenticated(true);

const nextPath = normalizePath(searchParams.get('path'));
// window.location.href = nextPath;

console.log('[DEBUG] ========== Navigation Info ==========');
console.log('[DEBUG] window.location.href:', window.location.href);
console.log('[DEBUG] window.location.pathname:', window.location.pathname);
console.log('[DEBUG] window.location.search:', window.location.search);
console.log('[DEBUG] searchParams.get("path"):', searchParams.get('path'));
console.log('[DEBUG] nextPath:', nextPath);
console.log('[DEBUG] Same pathname?', window.location.pathname === nextPath);
console.log('[DEBUG] =====================================');
try {
router.replace(nextPath);
console.log('[LOGIN] router.replace called successfully');
} catch (e) {
console.error('[LOGIN] router.replace threw error:', e);
}
router.replace(nextPath);
} catch (error) {
if (isCommonErrorResponse(error)) {
console.error('[LOGIN ERROR]', error.errorCode, error.detail);
Expand Down
4 changes: 2 additions & 2 deletions src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';

export default async function proxy(request: NextRequest) {
const accessToken = request.cookies.get('accessToken');
// const accessToken = request.cookies.get('accessToken');
const refreshToken = request.cookies.get('refreshToken');

const protectedPaths = ['/mypage', '/create-group', '/message', '/schedule', '/notification'];
Expand All @@ -13,7 +13,7 @@ export default async function proxy(request: NextRequest) {
}

// 둘 다 없으면 로그인 페이지로 redirect
if (!accessToken && !refreshToken) {
if (!refreshToken) {
const loginUrl = new URL('/login', request.url);
loginUrl.searchParams.set('error', 'unauthorized');
loginUrl.searchParams.set('path', request.nextUrl.pathname);
Expand Down