Skip to content

Commit 15f963c

Browse files
Maksym Nebliienkonkavian
authored andcommitted
fix(core): default to the production API host, keep single-URL override
Data endpoints default to https://api.inflowpay.ai and OAuth/device auth to https://app.inflowpay.ai in production; a single INFLOW_BASE_URL (or apiBaseUrl) override still redirects both, so targeting another environment stays a one-variable change.
1 parent 344f9cb commit 15f963c

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

.changeset/spicy-hosts-default.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@inflowpayai/inflow': patch
3+
---
4+
5+
Default the production API base URL to `https://api.inflowpay.ai` for data endpoints, while OAuth/device auth keeps
6+
using `https://app.inflowpay.ai`. A single `INFLOW_BASE_URL` (or `apiBaseUrl`) override still redirects both hosts, so
7+
pointing the CLI at another environment stays a one-variable change.

packages/core/src/config.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ export interface ResolvedInflowSdkConfig {
4545
type AuthMode = ResolvedInflowSdkConfig['authMode'];
4646

4747
/** @internal */
48-
export const ENVIRONMENT_BASE_URLS: Record<InflowEnvironment, string> = {
48+
export const ENVIRONMENT_API_BASE_URLS: Record<InflowEnvironment, string> = {
49+
production: 'https://api.inflowpay.ai',
50+
sandbox: 'https://sandbox.inflowpay.ai',
51+
};
52+
53+
/** @internal */
54+
export const ENVIRONMENT_AUTH_BASE_URLS: Record<InflowEnvironment, string> = {
4955
production: 'https://app.inflowpay.ai',
5056
sandbox: 'https://sandbox.inflowpay.ai',
5157
};
@@ -58,7 +64,9 @@ export const ENVIRONMENT_BASE_URLS: Record<InflowEnvironment, string> = {
5864
*/
5965
export function resolveApiBaseUrl(options: Pick<InflowOptions, 'apiBaseUrl' | 'environment'>): string {
6066
return (
61-
options.apiBaseUrl ?? process.env['INFLOW_BASE_URL'] ?? ENVIRONMENT_BASE_URLS[options.environment ?? 'production']
67+
options.apiBaseUrl ??
68+
process.env['INFLOW_BASE_URL'] ??
69+
ENVIRONMENT_API_BASE_URLS[options.environment ?? 'production']
6270
);
6371
}
6472

@@ -139,9 +147,14 @@ export function resolveInflowSdkConfig(options: InflowOptions = {}): ResolvedInf
139147
const logger = options.logger ?? createDefaultLogger(verbose);
140148
const environment: InflowEnvironment = options.environment ?? 'production';
141149

142-
const apiBaseUrl = options.apiBaseUrl ?? process.env['INFLOW_BASE_URL'] ?? ENVIRONMENT_BASE_URLS[environment];
150+
const explicitApiBaseUrl = options.apiBaseUrl ?? process.env['INFLOW_BASE_URL'];
151+
const apiBaseUrl = explicitApiBaseUrl ?? ENVIRONMENT_API_BASE_URLS[environment];
143152

144-
const authBaseUrl = options.authBaseUrl ?? process.env['INFLOW_AUTH_BASE_URL'] ?? apiBaseUrl;
153+
const authBaseUrl =
154+
options.authBaseUrl ??
155+
process.env['INFLOW_AUTH_BASE_URL'] ??
156+
explicitApiBaseUrl ??
157+
ENVIRONMENT_AUTH_BASE_URLS[environment];
145158

146159
const cliClientId = options.cliClientId ?? process.env['INFLOW_CLI_CLIENT_ID'];
147160

packages/core/test/unit/config.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('resolveInflowSdkConfig', () => {
1919
it('defaults environment to production and apiBaseUrl', () => {
2020
const c = resolveInflowSdkConfig();
2121
expect(c.environment).toBe('production');
22-
expect(c.apiBaseUrl).toBe('https://app.inflowpay.ai');
22+
expect(c.apiBaseUrl).toBe('https://api.inflowpay.ai');
2323
expect(c.authBaseUrl).toBe('https://app.inflowpay.ai');
2424
expect(c.clientName).toBe('InFlow');
2525
});
@@ -46,6 +46,13 @@ describe('resolveInflowSdkConfig', () => {
4646
expect(c.authBaseUrl).toBe('https://opt');
4747
});
4848

49+
it('INFLOW_BASE_URL alone redirects both apiBaseUrl and authBaseUrl', () => {
50+
process.env['INFLOW_BASE_URL'] = 'https://dev.inflowpay.ai';
51+
const c = resolveInflowSdkConfig();
52+
expect(c.apiBaseUrl).toBe('https://dev.inflowpay.ai');
53+
expect(c.authBaseUrl).toBe('https://dev.inflowpay.ai');
54+
});
55+
4956
it('authBaseUrl env overrides default', () => {
5057
process.env['INFLOW_AUTH_BASE_URL'] = 'https://auth.test';
5158
const c = resolveInflowSdkConfig();

packages/core/test/unit/flows/inflow-flows.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('Inflow augmented surface', () => {
110110

111111
it('resolvedApiBaseUrl defaults to the environment-derived URL when no explicit apiBaseUrl is set', () => {
112112
const prodClient = new Inflow({ environment: 'production' });
113-
expect(prodClient.resolvedApiBaseUrl).toBe('https://app.inflowpay.ai');
113+
expect(prodClient.resolvedApiBaseUrl).toBe('https://api.inflowpay.ai');
114114
const sandboxClient = new Inflow({ environment: 'sandbox' });
115115
expect(sandboxClient.resolvedApiBaseUrl).toBe('https://sandbox.inflowpay.ai');
116116
});

0 commit comments

Comments
 (0)