mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-12 23:31:02 +00:00
12 lines
470 B
TypeScript
12 lines
470 B
TypeScript
import { useState, useEffect } from 'react'
|
|
import { getAuthUrl } from '../../api/authUrl'
|
|
|
|
// Authenticated image — fetches a short-lived download token and renders the image
|
|
export function AuthedImg({ src, style }: { src: string; style?: React.CSSProperties }) {
|
|
const [authSrc, setAuthSrc] = useState('')
|
|
useEffect(() => {
|
|
void getAuthUrl(src, 'download').then(setAuthSrc)
|
|
}, [src])
|
|
return authSrc ? <img src={authSrc} alt="" style={style} /> : null
|
|
}
|