import fetch from 'cross-fetch' ; import { filterMovieData } from '../filterMovieData' ; import type { MovieDetails } from '../types' ; import type { PageContextBuiltIn } from 'vite-plugin-ssr' ; export { onBeforeRender } ; async function onBeforeRender ( pageContext ) { const response = await fetch ( `https://star-wars.brillout.com/api/films/${ pageContext . routeParams . movieId }.json` ) ; let movie = ( await response . json ( ) ) as MovieDetails ; movie = filterMovieData ( movie ) ; const { title } = movie ; return { pageContext : { pageProps : { movie , } , documentProps : { title , } , } , } ; }