Added base URL detection