Skip to content

Commit 54d1083

Browse files
authored
Merge pull request #1834 from hey-api/chore/platform-localhost-path
chore: support running platform on localhost
2 parents 59ee89a + 6657925 commit 54d1083

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/openapi-ts/src/createClient.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { postProcessClient } from './utils/postprocess';
1515

1616
const isPlatformPath = (path: string) =>
1717
path.startsWith('https://get.heyapi.dev');
18+
// || path.startsWith('http://localhost:4000')
1819

1920
export const compileInputPath = (input: Config['input']) => {
2021
const result: Pick<
@@ -106,7 +107,20 @@ export const compileInputPath = (input: Config['input']) => {
106107

107108
const query = queryParams.join('&');
108109
const platformUrl = baseUrl || 'get.heyapi.dev';
109-
const compiledPath = `https://${[platformUrl, result.organization, result.project].join('/')}`;
110+
const isLocalhost = platformUrl.startsWith('localhost');
111+
const platformUrlWithProtocol = [
112+
isLocalhost ? 'http' : 'https',
113+
platformUrl,
114+
].join('://');
115+
const compiledPath = isLocalhost
116+
? [
117+
platformUrlWithProtocol,
118+
'v1',
119+
'get',
120+
result.organization,
121+
result.project,
122+
].join('/')
123+
: [platformUrlWithProtocol, result.organization, result.project].join('/');
110124
result.path = query ? `${compiledPath}?${query}` : compiledPath;
111125

112126
return result;

0 commit comments

Comments
 (0)