fix: add origin to preview message (#23059)

* fix: add origin to preview message

* Update packages/core/content-manager/admin/src/preview/components/PreviewHeader.tsx

Co-authored-by: markkaylor <mark.kaylor@strapi.io>

---------

Co-authored-by: markkaylor <mark.kaylor@strapi.io>
This commit is contained in:
Rémi de Juvigny 2025-03-05 09:55:33 +01:00 committed by GitHub
parent 614aaf36aa
commit 4ebc804985
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -185,7 +185,11 @@ const UnstablePreviewHeader = () => {
document,
meta,
onPreview: () => {
iframeRef?.current?.contentWindow?.postMessage({ type: 'strapiUpdate' });
iframeRef?.current?.contentWindow?.postMessage(
{ type: 'strapiUpdate' },
// The iframe origin is safe to use since it must be provided through the allowedOrigins config
new URL(iframeRef.current.src).origin
);
},
} satisfies DocumentActionProps;

View File

@ -8,7 +8,7 @@ import {
Form as FormContext,
} from '@strapi/admin/strapi-admin';
import { Box, Flex, FocusTrap, IconButton, Portal } from '@strapi/design-system';
import { ArrowLeft } from '@strapi/icons';
import { ArrowLineLeft } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { useLocation, useParams } from 'react-router-dom';
import { styled } from 'styled-components';
@ -47,7 +47,7 @@ const [PreviewProvider, usePreviewContext] = createContext<PreviewContextValue>(
* PreviewPage
* -----------------------------------------------------------------------------------------------*/
const AnimatedArrow = styled(ArrowLeft)<{ isSideEditorOpen: boolean }>`
const AnimatedArrow = styled(ArrowLineLeft)<{ isSideEditorOpen: boolean }>`
will-change: transform;
rotate: ${(props) => (props.isSideEditorOpen ? '0deg' : '180deg')};
transition: rotate 0.2s ease-in-out;