|
|
@ -1,7 +1,7 @@
|
|
|
|
import MovieDetails from '@app/components/MovieDetails';
|
|
|
|
import MovieDetails from '@app/components/MovieDetails';
|
|
|
|
import type { MovieDetails as MovieDetailsType } from '@server/models/Movie';
|
|
|
|
import type { MovieDetails as MovieDetailsType } from '@server/models/Movie';
|
|
|
|
import axios from 'axios';
|
|
|
|
import axios from 'axios';
|
|
|
|
import type { NextPage } from 'next';
|
|
|
|
import type { GetServerSideProps, NextPage } from 'next';
|
|
|
|
|
|
|
|
|
|
|
|
interface MoviePageProps {
|
|
|
|
interface MoviePageProps {
|
|
|
|
movie?: MovieDetailsType;
|
|
|
|
movie?: MovieDetailsType;
|
|
|
@ -11,25 +11,25 @@ const MoviePage: NextPage<MoviePageProps> = ({ movie }) => {
|
|
|
|
return <MovieDetails movie={movie} />;
|
|
|
|
return <MovieDetails movie={movie} />;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MoviePage.getInitialProps = async (ctx) => {
|
|
|
|
export const getServerSideProps: GetServerSideProps<MoviePageProps> = async (
|
|
|
|
if (ctx.req) {
|
|
|
|
ctx
|
|
|
|
const response = await axios.get<MovieDetailsType>(
|
|
|
|
) => {
|
|
|
|
`http://localhost:${process.env.PORT || 5055}/api/v1/movie/${
|
|
|
|
const response = await axios.get<MovieDetailsType>(
|
|
|
|
ctx.query.movieId
|
|
|
|
`http://localhost:${process.env.PORT || 5055}/api/v1/movie/${
|
|
|
|
}`,
|
|
|
|
ctx.query.movieId
|
|
|
|
{
|
|
|
|
}`,
|
|
|
|
headers: ctx.req?.headers?.cookie
|
|
|
|
{
|
|
|
|
? { cookie: ctx.req.headers.cookie }
|
|
|
|
headers: ctx.req?.headers?.cookie
|
|
|
|
: undefined,
|
|
|
|
? { cookie: ctx.req.headers.cookie }
|
|
|
|
}
|
|
|
|
: undefined,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
props: {
|
|
|
|
movie: response.data,
|
|
|
|
movie: response.data,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default MoviePage;
|
|
|
|
export default MoviePage;
|
|
|
|