mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix: corrected initial fallback data load on details page (#3395)
This commit is contained in:
@@ -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,8 +11,9 @@ 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>(
|
const response = await axios.get<MovieDetailsType>(
|
||||||
`http://localhost:${process.env.PORT || 5055}/api/v1/movie/${
|
`http://localhost:${process.env.PORT || 5055}/api/v1/movie/${
|
||||||
ctx.query.movieId
|
ctx.query.movieId
|
||||||
@@ -25,11 +26,10 @@ MoviePage.getInitialProps = async (ctx) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
props: {
|
||||||
movie: response.data,
|
movie: response.data,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MoviePage;
|
export default MoviePage;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import TvDetails from '@app/components/TvDetails';
|
import TvDetails from '@app/components/TvDetails';
|
||||||
import type { TvDetails as TvDetailsType } from '@server/models/Tv';
|
import type { TvDetails as TvDetailsType } from '@server/models/Tv';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import type { NextPage } from 'next';
|
import type { GetServerSideProps, NextPage } from 'next';
|
||||||
|
|
||||||
interface TvPageProps {
|
interface TvPageProps {
|
||||||
tv?: TvDetailsType;
|
tv?: TvDetailsType;
|
||||||
@@ -11,12 +11,11 @@ const TvPage: NextPage<TvPageProps> = ({ tv }) => {
|
|||||||
return <TvDetails tv={tv} />;
|
return <TvDetails tv={tv} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
TvPage.getInitialProps = async (ctx) => {
|
export const getServerSideProps: GetServerSideProps<TvPageProps> = async (
|
||||||
if (ctx.req) {
|
ctx
|
||||||
|
) => {
|
||||||
const response = await axios.get<TvDetailsType>(
|
const response = await axios.get<TvDetailsType>(
|
||||||
`http://localhost:${process.env.PORT || 5055}/api/v1/tv/${
|
`http://localhost:${process.env.PORT || 5055}/api/v1/tv/${ctx.query.tvId}`,
|
||||||
ctx.query.tvId
|
|
||||||
}`,
|
|
||||||
{
|
{
|
||||||
headers: ctx.req?.headers?.cookie
|
headers: ctx.req?.headers?.cookie
|
||||||
? { cookie: ctx.req.headers.cookie }
|
? { cookie: ctx.req.headers.cookie }
|
||||||
@@ -25,11 +24,10 @@ TvPage.getInitialProps = async (ctx) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
props: {
|
||||||
tv: response.data,
|
tv: response.data,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TvPage;
|
export default TvPage;
|
||||||
|
Reference in New Issue
Block a user