Next.js Discord

Discord Forum

Iframe loading problems in next.js 14

Unanswered
Flemish Giant posted this in #help-forum
Open in Discord
Avatar
Flemish GiantOP
I tried to get some yt urls via youtube api and use them on my website via iframe tags, however I'm keep getting this error:
"TypeError: Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy with name "default" already exists."
import fetchPlaylistItems from "@/lib/fetchPlaylistItems";
import React from "react";

const ProjectsPage = async () => {
  const data = await fetchPlaylistItems();

  switch (data) {
    case -1:
      return <>Nie zostały dodane żadne filmy na witrynę</>;
    default:
      return (
        <div className="min-w-screen mx-auto grid max-w-2xl gap-8 px-4 pb-16 pt-32">
          {data.map((video) => {
            const href = `https://www.youtube.com/embed/${video.contentDetails.videoId}`;
            if (!video.contentDetails.videoId) return null;
            return (
              <iframe
                className=" aspect-video w-full"
                key={`yt-vide-project-${video.id}`}
                src={href}
                allowFullScreen
                title={video.snippet.title}
              />
            );
          })}
        </div>
      );
  }
};

export default ProjectsPage;

2 Replies

Avatar
Flemish GiantOP
Also my console look like this cuz of that
Image