juspay/hyperswitch · error · Error
Unsupported baseUrl
Error message
Unsupported baseUrl
What it means
Thrown by validateEnv in RequestBodyUtils when baseUrl is non-empty but does not contain any key of keyPrefixes as a substring — the map only knows 'localhost', 'integ' and 'sandbox'. The substring match (baseUrl.includes(env)) is crude, so any other hostname fails, including perfectly valid production-style URLs.
Source
Thrown at cypress-tests-v2/cypress/utils/RequestBodyUtils.js:38
const tomorrow = new Date(now);
tomorrow.setDate(now.getDate() + 1);
// Convert to ISO string format
const isoStringTomorrow = tomorrow.toISOString();
return isoStringTomorrow;
}
export function validateEnv(baseUrl, keyIdType) {
if (!baseUrl) {
throw new Error("Please provide a baseUrl");
}
const environment = Object.keys(keyPrefixes).find((env) =>
baseUrl.includes(env)
);
if (!environment) {
throw new Error("Unsupported baseUrl");
}
const prefix = keyPrefixes[environment][keyIdType];
if (!prefix) {
throw new Error(`Unsupported keyIdType: ${keyIdType}`);
}
return prefix;
}
View on GitHub (pinned to 9b8b89dc37)
Solutions
- Use a baseUrl that literally contains one of: localhost, integ, sandbox (e.g. https://sandbox.hyperswitch.io)
- If the environment is legitimate, add its substring and key prefixes to keyPrefixes in RequestBodyUtils.js
- For local runs, prefer http://localhost:8080 so the existing 'localhost' entry matches
Example fix
// before (keyPrefixes only knows localhost / integ / sandbox)
const keyPrefixes = {
localhost: { publishable_key: 'pk_dev_', key_id: 'dev_' },
integ: { publishable_key: 'pk_snd_', key_id: 'snd_' },
sandbox: { publishable_key: 'pk_snd_', key_id: 'snd_' },
};
// after (teach it the new environment)
const keyPrefixes = {
localhost: { publishable_key: 'pk_dev_', key_id: 'dev_' },
integ: { publishable_key: 'pk_snd_', key_id: 'snd_' },
sandbox: { publishable_key: 'pk_snd_', key_id: 'snd_' },
staging: { publishable_key: 'pk_stg_', key_id: 'stg_' },
}; Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_ENVS = ['localhost', 'integ', 'sandbox'];
const baseUrl = Cypress.env('baseUrl');
if (!KNOWN_ENVS.some((env) => baseUrl.includes(env))) {
throw new Error(
`baseUrl must contain one of ${KNOWN_ENVS.join(', ')} (got ${baseUrl}). Add the environment to keyPrefixes if it is legitimate.`
);
} Prevention
- Keep environment tokens in hostnames so substring routing keeps working (e.g. sandbox.example.com)
- When onboarding a new environment, update keyPrefixes in RequestBodyUtils.js in the same change
- Remember the check is substring-based: a URL that does not contain localhost/integ/sandbox will never match
When it happens
Trigger: Calling validateEnv('https://api.hyperswitch.io', ...) (no known substring), or a custom CI hostname like 'https://router.staging.internal:8080' where none of localhost/integ/sandbox appear in the URL.
Common situations: Pointing the suite at a new/private environment; a URL rewrite/proxy that hides the environment token; renaming environments without updating keyPrefixes; using 'integration' in the URL which does NOT contain 'integ' as substring... note 'integration' does contain 'integ', but e.g. 'prod' or 'staging' does not.
Related errors
- Please provide a baseUrl
- Unsupported keyIdType: ${keyIdType}
- Invalid config: missing path
- Missing proxyHttp or proxyHttps in globalState. globalState.
- Missing connectorId or methodFlow in globalState
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/a4525eb4595a3c96.
Report an issue: GitHub.