fix: SSRF issue

This commit is contained in:
AzizbekFayziyev 2026-01-17 19:16:10 +05:00
parent 8bbe44d2cf
commit 65568e8cfb
2 changed files with 4 additions and 5 deletions

View file

@ -12,7 +12,6 @@ import Popup from '@/components/UI/Popup/Popup';
import CreateOfferPopup from '@/components/default/CreateOfferPopup/CreateOfferPopup';
import Link from 'next/link';
import MainPageTitle from '@/components/default/MainPageTitle/MainPageTitle';
import { GetServerSidePropsContext } from 'next';
import HomeProps from '@/interfaces/props/pages/p2p/HomeProps';
import OfferData from '@/interfaces/responses/offers/OfferData';
import { useRouter } from 'next/router';
@ -103,8 +102,8 @@ function Home(props: HomeProps) {
);
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
const stats = await getStats(context.req.headers.host);
export async function getServerSideProps() {
const stats = await getStats();
return {
props: {

View file

@ -74,8 +74,8 @@ export async function getPage(
.then((res) => res.data);
}
export async function getStats(host: string | undefined = undefined): Promise<GetStatsRes> {
return (await fetch(`${host ? `https://${host}` : ''}/api/offers/get-stats`).then((res) =>
export async function getStats(): Promise<GetStatsRes> {
return (await fetch(`${baseUrl}/api/offers/get-stats`).then((res) =>
res.json(),
)) as GetStatsRes;
}