feat(route/youtube): Allow configuring custom embed url (#21248)

This commit is contained in:
Thomas
2026-03-01 00:28:45 +08:00
committed by GitHub
parent e935df5bc6
commit 7465febbdf
2 changed files with 13 additions and 1 deletions
+3
View File
@@ -236,6 +236,7 @@ type ConfigEnvKeys =
| 'YOUTUBE_CLIENT_ID'
| 'YOUTUBE_CLIENT_SECRET'
| 'YOUTUBE_REFRESH_TOKEN'
| 'YOUTUBE_VIDEO_EMBED_URL'
| 'ZHIHU_COOKIES'
| 'ZODGAME_COOKIE'
| 'ZSXQ_ACCESS_TOKEN'
@@ -675,6 +676,7 @@ export type Config = {
clientId?: string;
clientSecret?: string;
refreshToken?: string;
videoEmbedUrl?: string;
};
zhihu: {
cookies?: string;
@@ -1164,6 +1166,7 @@ const calculateValue = () => {
clientId: envs.YOUTUBE_CLIENT_ID,
clientSecret: envs.YOUTUBE_CLIENT_SECRET,
refreshToken: envs.YOUTUBE_REFRESH_TOKEN,
videoEmbedUrl: envs.YOUTUBE_VIDEO_EMBED_URL || 'https://www.youtube-nocookie.com/embed/',
},
zhihu: {
cookies: envs.ZHIHU_COOKIES,
+10 -1
View File
@@ -68,7 +68,16 @@ export const renderDescription = (embed, videoId, img, description) =>
renderToString(
<>
{embed ? (
<iframe id="ytplayer" type="text/html" width="640" height="360" src={`https://www.youtube-nocookie.com/embed/${videoId}`} frameborder="0" allowfullscreen referrerpolicy="strict-origin-when-cross-origin" />
<iframe
id="ytplayer"
type="text/html"
width="640"
height="360"
src={(config.youtube?.videoEmbedUrl || 'https://www.youtube-nocookie.com/embed/') + videoId}
frameborder="0"
allowfullscreen
referrerpolicy="strict-origin-when-cross-origin"
/>
) : (
<img src={img?.url ?? ''} />
)}