Raju2024's picture
Upload 1072 files
e3278e4 verified
raw
history blame contribute delete
384 Bytes
// useBaseUrl.ts
import { useState, useEffect } from 'react';
export const useBaseUrl = () => {
const [baseUrl, setBaseUrl] = useState("http://localhost:4000");
useEffect(() => {
if (typeof window !== 'undefined') {
const { protocol, host } = window.location;
setBaseUrl(`${protocol}//${host}`);
}
}, []); // Removed router dependency
return baseUrl;
};