// 定义后端服务URL和OAuth2配置
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? ""

const CLIENT_ID = import.meta.env.VITE_CLIENT_ID
if (!CLIENT_ID) throw new Error("VITE_CLIENT_ID is not set")

const CLIENT_SECRET = import.meta.env.VITE_CLIENT_SECRET
if (!CLIENT_SECRET) throw new Error("VITE_CLIENT_SECRET is not set")

// 统一的API响应类型
type ApiResponse<T = undefined> =
  | {
      success: false
      status?: number
      message: string
    }
  | {
      success: true
      data: T
      // 响应头（key 统一小写），用于登录等场景从 header 取数据
      headers?: Record<string, string>
    }

export { API_BASE_URL, type ApiResponse, CLIENT_ID, CLIENT_SECRET }
