I'm trying to embed a youtube video in my next.js web app. Everything works fine from the "functional" point of view, however Chrome highlight the following issue related to cookies (NOTICE: I'm already using the no-cookie
url version, as you will see in the link of the iframe):
Indicate whether a cookie is intended to be set in a cross-site context by specifying its
SameSite attribute
I understand the underlying problem: youtube is trying to set a cookie and since it is a cross-origin request the browser raise an issue. However, I want to understand how to solve the problem using next.
Just to give further information I'm using nginx as webserver and pm2 to run nextjs server-side.
This is the iframe:
<iframe
className="relative left-1/2 -translate-x-1/2 h-60 2xs:h-80 xs:h-96 lg:h-100 w-full sm:w-2/3"
src="https://www.youtube-nocookie.com/embed/s563j8bP6eE"
title="YouTube video player"
frameBorder={"0"}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen />
CLARIFICATIONS: The purpose of this question is NOT to ask how can I disable cookies warnings (which is explained in a different answer like this one: link), but instead I want to ask if there was a way to configure Youtube FramerAPI to avoid the issue.
Update:
I've managed to deploy my application on a server (with HTTPS) and it doesn't raise any issue. The issue might be related to local development without HTTPS.