Skip to content

Conversation

@perbergland
Copy link
Contributor

Fixes #109

@perbergland
Copy link
Contributor Author

This fix was verified by putting the same video side by side. The one via LiteYouTubeEmbed fails 50% of the times with error 153.
The "raw" iframe in the example works 100% of the time.
Adding the referrerPolicy in the ref callback did not help.

image

videoId=M7FIvfx5J10

<Box
        sx={{ display: "flex", flexDirection: "column", gap: 2 }}
        key={props.key}
      >
        <LiteYouTubeEmbed
          id={videoId}
          title={props.alt}
          params={parameters}
          key={props.key}
          alwaysLoadIframe          
          ref={(iframeRef) => {
            if (iframeRef) {
              iframeRef.referrerPolicy = "strict-origin-when-cross-origin";
            }
          }}
        />
        <iframe
          title={props.alt}
          width="500"
          height="500"
          src={`https://www.youtube-nocookie.com/embed/${videoId}?${parameters}`}
          referrerPolicy="strict-origin-when-cross-origin"
        />
      </Box>

@ibrahimcesar
Copy link
Owner

LGTM

@ibrahimcesar ibrahimcesar merged commit b591866 into ibrahimcesar:main Nov 3, 2025
1 check passed
@janderson-watchbox
Copy link

https://www.npmjs.com/package/react-lite-youtube-embed?activeTab=versions the published v2.5.6 does not match the release here.. will there be a new version with this fix published for npm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embed doesn't add referrerpolicy

3 participants