- API 키 로그인 다이얼로그 + 헤더 로그인 버튼 - /api/character/list 프록시 엔드포인트 (월드 아이콘 매핑 포함) - 캐릭터 입력 포커스 시 드롭다운 (월드 아이콘, 레벨 정렬, 기존 캐릭 제외, 페이드 애니메이션) - 관리자 인증을 API 키로 통합 (URL ?key= 파라미터 폐기) - 헤더에 관리자 링크 버튼 / 홈 링크 버튼 (경로별 배타적 표시) - 관리자 페이지에서 타이틀 우측에 "관리자" 텍스트 - 이미지 관리 페이지 테마 토큰화 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
27 lines
808 B
JavaScript
27 lines
808 B
JavaScript
import { useAuthStore } from '../stores/auth'
|
|
|
|
export async function api(url, options = {}) {
|
|
const headers = { 'Content-Type': 'application/json', ...options.headers }
|
|
|
|
// 관리자 API에는 로그인 다이얼로그에서 저장한 키를 자동으로 헤더에 포함
|
|
if (url.startsWith('/api/admin')) {
|
|
const adminKey = useAuthStore.getState().apiKey
|
|
if (adminKey) headers['x-admin-key'] = adminKey
|
|
}
|
|
|
|
const res = await fetch(url, {
|
|
credentials: 'include',
|
|
...options,
|
|
headers,
|
|
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
})
|
|
|
|
if (!res.ok) {
|
|
const error = await res.json().catch(() => ({}))
|
|
const e = new Error(error.error || `HTTP ${res.status}`)
|
|
Object.assign(e, error, { status: res.status })
|
|
throw e
|
|
}
|
|
|
|
return res.json()
|
|
}
|