diff --git a/packages/oas-to-har/src/index.ts b/packages/oas-to-har/src/index.ts index ecd2edd9..279f4bb1 100644 --- a/packages/oas-to-har/src/index.ts +++ b/packages/oas-to-har/src/index.ts @@ -222,11 +222,7 @@ export default function oasToHar( operationSchema?: Operation, values: DataForHAR = {}, auth: AuthForHAR = {}, - opts: oasToHarOptions = { - // If true, the operation URL will be rewritten and prefixed with https://try.readme.io/ in - // order to funnel requests through our CORS-friendly proxy. - proxyUrl: false, - }, + opts: oasToHarOptions = { proxyUrl: '' }, ) { let operation: Operation; if (!operationSchema || typeof operationSchema.getParameters !== 'function') { @@ -287,7 +283,7 @@ export default function oasToHar( if (opts.proxyUrl) { if (oas.getExtension(PROXY_ENABLED, operation)) { - har.url = `https://try.readme.io/${har.url}`; + har.url = `${opts.proxyUrl}/${har.url}`; } } diff --git a/packages/oas-to-har/src/lib/types.ts b/packages/oas-to-har/src/lib/types.ts index b84f548b..63ad11ea 100644 --- a/packages/oas-to-har/src/lib/types.ts +++ b/packages/oas-to-har/src/lib/types.ts @@ -3,7 +3,10 @@ export type AuthForHAR = Record { }); }); - it('should not be prefixed with without option', () => { + it('should not be prefixed without proxyUrl', () => { const har = oasToHar(proxyOas, proxyOas.operation('/path', 'get')); expect(har.log.entries[0].request.url).toBe('https://example.com/path'); }); - it('should be prefixed with try.readme.io with option', () => { - const har = oasToHar(proxyOas, proxyOas.operation('/path', 'get'), {}, {}, { proxyUrl: true }); + it('should be prefixed with proxyUrl', () => { + const har = oasToHar( + proxyOas, + proxyOas.operation('/path', 'get'), + {}, + {}, + { proxyUrl: 'https://try.readme.io' }, + ); expect(har.log.entries[0].request.url).toBe('https://try.readme.io/https://example.com/path'); }); });