This commit is contained in:
dsyoon
2025-08-18 16:01:06 +09:00
parent f3355d8b69
commit 7832f2c384
7 changed files with 28 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import React, { createContext, useContext, useEffect, useState } from 'react';
import { API_BASE_URL } from '../config';
const AuthContext = createContext();
@@ -15,7 +16,7 @@ export function AuthProvider({ children }) {
}, []);
const login = async (email, password) => {
const res = await fetch('http://localhost:8010/auth/login', {
const res = await fetch(`${API_BASE_URL}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
@@ -35,7 +36,7 @@ export function AuthProvider({ children }) {
const logout = async () => {
try {
await fetch('http://localhost:8010/auth/logout', { method: 'POST', credentials: 'include' });
await fetch(`${API_BASE_URL}/auth/logout`, { method: 'POST', credentials: 'include' });
} catch {}
setUser(null);
try { localStorage.removeItem('auth_user'); } catch {}