msfragala / sanity-plugin-youtube-input

MIT License
7 stars 4 forks source link

“YouTube video not found” #2

Open patrulea opened 10 months ago

patrulea commented 10 months ago

For some reason, I can’t get the plugin to work. All I get is “YouTube video not found” as soon as I enter any video URL.

image

Video tested: https://www.youtube.com/watch?v=G0zw8Mn0GRA

patrulea commented 10 months ago

This is my Sanity configuration file.

import { youtubeInput } from "sanity-plugin-youtube-input"

export default defineConfig({
  // [...]
  plugins: [
    youtubeInput({
      apiKey: process.env.SANITY_STUDIO_YOUTUBE_API_KEY
    })
  ]
})
alyyasser19 commented 10 months ago

I was facing the same issue, turns out to be because I didn't enable YouTube Data API v3 on the Google API console, once enabled the issue was fixed.

check out the steps here.

andrewmumblebee commented 8 months ago

I had a similar issue, if you're using NextJS to host your studio frontend, you need to store your environment variable as NEXT_PUBLIC_YOUTUBE_API_KEY

Then use process.env.NEXT_PUBLIC_YOUTUBE_API_KEY to retrieve it, this was the only way i've been able to get env variables to work, as the fs package doesn't work in sanity.config.ts

Seems like it's related to this line but I'm not 100% sure.

As long as you don't use that environment variable in your frontend code, it should only be exposed in Sanity Studio as NextJS replaces the references inline.

Hope this helps anyone else having this issue.