diff --git a/packages/insomnia/src/ui/components/mocks/mock-url-bar.tsx b/packages/insomnia/src/ui/components/mocks/mock-url-bar.tsx index 84fea65b2..5a982d5c1 100644 --- a/packages/insomnia/src/ui/components/mocks/mock-url-bar.tsx +++ b/packages/insomnia/src/ui/components/mocks/mock-url-bar.tsx @@ -153,7 +153,7 @@ export const MockUrlBar = ({ onPathUpdate, onSend }: { onPathUpdate: (path: stri label="Generate Client Code" onClick={async () => { const request = await models.request.getByParentId(mockRoute._id); - request && showModal(GenerateCodeModal, { request }); + request && showModal(GenerateCodeModal, { request: { ...request, url: getMockServiceBinURL(mockRoute.parentId, pathInput, mockServer.useInsomniaCloud ? undefined : mockServer.url) } }); }} /> diff --git a/packages/insomnia/src/ui/components/modals/generate-code-modal.tsx b/packages/insomnia/src/ui/components/modals/generate-code-modal.tsx index 42b61d789..fca292486 100644 --- a/packages/insomnia/src/ui/components/modals/generate-code-modal.tsx +++ b/packages/insomnia/src/ui/components/modals/generate-code-modal.tsx @@ -1,7 +1,7 @@ import type { HTTPSnippetClient, HTTPSnippetTarget } from 'httpsnippet'; import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react'; -import { exportHarRequest } from '../../../common/har'; +import { exportHarWithRequest } from '../../../common/har'; import { Request } from '../../../models/request'; import { CopyButton } from '../base/copy-button'; import { Dropdown, DropdownButton, DropdownItem, ItemContent } from '../base/dropdown'; @@ -81,7 +81,7 @@ export const GenerateCodeModal = forwardRef((pro // Some clients need a content-length for the request to succeed const addContentLength = Boolean((TO_ADD_CONTENT_LENGTH[targetOrFallback.key] || []).find(c => c === clientOrFallback.key)); - const har = await exportHarRequest(request._id, props.environmentId, addContentLength); + const har = await exportHarWithRequest(request, props.environmentId, addContentLength); if (har) { const snippet = new HTTPSnippet(har); const cmd = snippet.convert(targetOrFallback.key, clientOrFallback.key) || '';