Fix migrations for build and iframe rendering

This commit is contained in:
Gregory Schier
2023-03-01 10:31:50 -08:00
parent baee0f0c6f
commit e352343d62
3 changed files with 21 additions and 14 deletions

View File

@@ -34,13 +34,14 @@ export function ResponsePane({ requestId, error }: Props) {
[response],
);
const contentForIframe: string = useMemo(() => {
if (response == null) return '';
const contentForIframe: string | null = useMemo(() => {
if (!contentType.includes('html')) return null;
if (response == null) return null;
if (response.body.includes('<head>')) {
return response.body.replace(/<head>/gi, `<head><base href="${response.url}"/>`);
}
return response.body;
}, [response?.id]);
}, [response?.body, contentType]);
return (
<VStack className="w-full">
@@ -97,7 +98,7 @@ export function ResponsePane({ requestId, error }: Props) {
)}
</HStack>
</HStack>
{viewMode === 'pretty' && contentType.includes('html') ? (
{viewMode === 'pretty' && contentForIframe !== null ? (
<iframe
title="Response preview"
srcDoc={contentForIframe}