Nextjs client receives the drive sharing urls from backend, I have to show them as embedded in iframe at nextjs clinet.
here is code implmented
if (file.includes("drive.google.com")) {
const previewUrl =
"https://drive.google.com/file/d/" + extractFileId(file) + "/preview?usp=drive_web";
return (
<iframe
title="Drivemedia"
onContextMenu={(e) => e.preventDefault()}
src={previewUrl}
onLoad={onLoad}
height="400"
width="100%"
className={`max-h-[400px] max-w-[698px] rounded-xl border border-gray-200 object-cover`}
referrerPolicy="strict-origin-when-cross-origin"
allow="autoplay; encrypted-media; gyroscope; picture-in-picture"
frameBorder={0}
scrolling="no"
seamless
/>
);
}
Above code results in following three error each file rendered,
-
Refused to frame ‘https://drive.google.com/’ because an ancestor violates the following Content Security Policy directive: “frame-ancestors https://drive.google.com”.
-
Error with Permissions-Policy header: Unrecognized feature: ‘ch-ua-form-factor’.
-
Refused to frame ‘https://accounts.google.com/’ because an ancestor violates the following Content Security Policy directive: “frame-ancestors https://drive.google.com”.