diff --git a/src/pages/movie/[movieId]/index.tsx b/src/pages/movie/[movieId]/index.tsx index 2bb971c18..053ee3ff3 100644 --- a/src/pages/movie/[movieId]/index.tsx +++ b/src/pages/movie/[movieId]/index.tsx @@ -1,7 +1,7 @@ import MovieDetails from '@app/components/MovieDetails'; import type { MovieDetails as MovieDetailsType } from '@server/models/Movie'; import axios from 'axios'; -import type { NextPage } from 'next'; +import type { GetServerSideProps, NextPage } from 'next'; interface MoviePageProps { movie?: MovieDetailsType; @@ -11,25 +11,25 @@ const MoviePage: NextPage = ({ movie }) => { return ; }; -MoviePage.getInitialProps = async (ctx) => { - if (ctx.req) { - const response = await axios.get( - `http://localhost:${process.env.PORT || 5055}/api/v1/movie/${ - ctx.query.movieId - }`, - { - headers: ctx.req?.headers?.cookie - ? { cookie: ctx.req.headers.cookie } - : undefined, - } - ); +export const getServerSideProps: GetServerSideProps = async ( + ctx +) => { + const response = await axios.get( + `http://localhost:${process.env.PORT || 5055}/api/v1/movie/${ + ctx.query.movieId + }`, + { + headers: ctx.req?.headers?.cookie + ? { cookie: ctx.req.headers.cookie } + : undefined, + } + ); - return { + return { + props: { movie: response.data, - }; - } - - return {}; + }, + }; }; export default MoviePage; diff --git a/src/pages/tv/[tvId]/index.tsx b/src/pages/tv/[tvId]/index.tsx index 69fe216fd..a8a3cbd7d 100644 --- a/src/pages/tv/[tvId]/index.tsx +++ b/src/pages/tv/[tvId]/index.tsx @@ -1,7 +1,7 @@ import TvDetails from '@app/components/TvDetails'; import type { TvDetails as TvDetailsType } from '@server/models/Tv'; import axios from 'axios'; -import type { NextPage } from 'next'; +import type { GetServerSideProps, NextPage } from 'next'; interface TvPageProps { tv?: TvDetailsType; @@ -11,25 +11,23 @@ const TvPage: NextPage = ({ tv }) => { return ; }; -TvPage.getInitialProps = async (ctx) => { - if (ctx.req) { - const response = await axios.get( - `http://localhost:${process.env.PORT || 5055}/api/v1/tv/${ - ctx.query.tvId - }`, - { - headers: ctx.req?.headers?.cookie - ? { cookie: ctx.req.headers.cookie } - : undefined, - } - ); +export const getServerSideProps: GetServerSideProps = async ( + ctx +) => { + const response = await axios.get( + `http://localhost:${process.env.PORT || 5055}/api/v1/tv/${ctx.query.tvId}`, + { + headers: ctx.req?.headers?.cookie + ? { cookie: ctx.req.headers.cookie } + : undefined, + } + ); - return { + return { + props: { tv: response.data, - }; - } - - return {}; + }, + }; }; export default TvPage;