feat: fetch images from media proxy on frontend
This commit is contained in:
@ -14,7 +14,7 @@ export default async function handler(
|
||||
|
||||
if (!mediaUrl) {
|
||||
res.status(400)
|
||||
res.send(null)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ export default async function handler(
|
||||
mediaUrlParsed = new URL(mediaUrl)
|
||||
} catch {
|
||||
res.status(400)
|
||||
res.send(null)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
@ -33,13 +33,13 @@ export default async function handler(
|
||||
|
||||
if (!mediaDomain.endsWith('media-amazon.com')) {
|
||||
res.status(400)
|
||||
res.send(null)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
if (mediaUrlParsed.protocol !== 'https:') {
|
||||
res.status(400)
|
||||
res.send(null)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ export default async function handler(
|
||||
|
||||
if (!validExtension) {
|
||||
res.status(400)
|
||||
res.send(null)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ export default async function handler(
|
||||
|
||||
if (!mediaRes.ok) {
|
||||
res.status(mediaRes.status)
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import { AppError } from '../../../interfaces/shared/error'
|
||||
// styles
|
||||
import styles from '../../../styles/modules/pages/title/title.module.scss'
|
||||
import Head from 'next/head'
|
||||
import { getProxiedIMDbImgUrl } from '../../../utils/helpers'
|
||||
|
||||
type Props = { data: Title; error: null } | { error: AppError; data: null }
|
||||
|
||||
@ -50,7 +51,11 @@ const TitleInfo = ({ data, error }: Props) => {
|
||||
<Head>
|
||||
<meta
|
||||
title="og:image"
|
||||
content={data.basic.poster?.url || '/icon-512.png'}
|
||||
content={
|
||||
data.basic.poster?.url
|
||||
? getProxiedIMDbImgUrl(data.basic.poster?.url)
|
||||
: '/icon-512.png'
|
||||
}
|
||||
/>
|
||||
</Head>
|
||||
<Layout className={styles.title}>
|
||||
|
Reference in New Issue
Block a user