import { getWebhookUrl } from '@/lib/config';

export async function refreshToken(): Promise<string | null> {
  const url = `${getWebhookUrl()}/auth/rnjwt`;
  const resp = await fetch(url, {
    method: 'GET',
    credentials: 'include',
  });
  if (!resp.ok) return null;
  try {
    const data = await resp.json();
    return typeof data?.token === 'string' ? data.token : null;
  } catch {
    return null;
  }
}
