const DEFAULT_BASE_URL = 'https://api.tamilculturewaterloo.org/api/';

const configuredBaseUrl =
	typeof process !== 'undefined' && process.env.NEXT_PUBLIC_API_BASE_URL
		? process.env.NEXT_PUBLIC_API_BASE_URL
		: DEFAULT_BASE_URL;

export const Baseurl = configuredBaseUrl.endsWith('/') ? configuredBaseUrl : `${configuredBaseUrl}/`;

export const buildApiUrl = (path) => {
	const normalizedPath = String(path).replace(/^\/+/, '');
	return `${Baseurl}${normalizedPath}`;
};