diff --git a/.changeset/seven-years-knock.md b/.changeset/seven-years-knock.md new file mode 100644 index 00000000..ca047d79 --- /dev/null +++ b/.changeset/seven-years-knock.md @@ -0,0 +1,6 @@ +--- +'@flatfile/configure': patch +'@flatfile/listener': patch +--- + +Remove fallback to localhost diff --git a/package-lock.json b/package-lock.json index 0f272421..45f49db8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37451,7 +37451,7 @@ }, "packages/javascript": { "name": "@flatfile/javascript", - "version": "1.5.1", + "version": "1.5.2", "license": "ISC", "dependencies": { "@flatfile/embedded-utils": "^1.3.4", diff --git a/packages/configure/src/utils/authenticated.client.ts b/packages/configure/src/utils/authenticated.client.ts index 6e08a9ef..252e6ca4 100644 --- a/packages/configure/src/utils/authenticated.client.ts +++ b/packages/configure/src/utils/authenticated.client.ts @@ -3,7 +3,7 @@ import { Configuration, DefaultApi } from '@flatfile/api' import fetch, { RequestInit } from 'node-fetch' const FLATFILE_API_URL = - process.env.AGENT_INTERNAL_URL || 'http://localhost:3000' + process.env.AGENT_INTERNAL_URL ?? 'https://platform.flatfile.com/api' export class AuthenticatedClient { private _api?: DefaultApi @@ -37,6 +37,9 @@ export class AuthenticatedClient { 'x-disable-hooks': 'true', ...options.headers, } + if (FLATFILE_API_URL == null) { + throw new Error('AGENT_INTERNAL_URL must be set in the environment') + } const fetchUrl = FLATFILE_API_URL + '/' + url return fetch(fetchUrl, { diff --git a/packages/listener/src/events/authenticated.client.ts b/packages/listener/src/events/authenticated.client.ts index 6d994acc..2f30db38 100644 --- a/packages/listener/src/events/authenticated.client.ts +++ b/packages/listener/src/events/authenticated.client.ts @@ -8,15 +8,17 @@ export class AuthenticatedClient { constructor(accessToken?: string, apiUrl?: string) { const FLATFILE_API_URL = - CrossEnvConfig.get('AGENT_INTERNAL_URL') || 'http://localhost:3000' + CrossEnvConfig.get('AGENT_INTERNAL_URL') ?? + apiUrl ?? + 'https://platform.flatfile.com/api' + const bearerToken = CrossEnvConfig.get('FLATFILE_BEARER_TOKEN') - this._accessToken = accessToken || bearerToken || '...' + this._accessToken = accessToken ?? bearerToken ?? '...' - this._apiUrl = - apiUrl || FLATFILE_API_URL - ? ensureSingleTrailingSlash(apiUrl || FLATFILE_API_URL) - : undefined + this._apiUrl = FLATFILE_API_URL + ? ensureSingleTrailingSlash(FLATFILE_API_URL) + : undefined } async fetch(url: string, options?: any) { diff --git a/packages/listener/src/events/event.handler.spec.ts b/packages/listener/src/events/event.handler.spec.ts index 8eb31205..d5b1f7d2 100644 --- a/packages/listener/src/events/event.handler.spec.ts +++ b/packages/listener/src/events/event.handler.spec.ts @@ -1,3 +1,4 @@ +import { CrossEnvConfig } from '@flatfile/cross-env-config' import { EventHandler } from './event.handler' describe('EventHandler', () => {