Skip to content

Commit a186559

Browse files
Ahmed ElywaAhmed Elywa
authored andcommitted
Fix city page API call to avoid 302 redirect caching issue
1 parent 1ad098b commit a186559

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/app/city/[slug]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export default async function CityPage({ params }: Props) {
4242
let timings: Record<string, string> | null = null;
4343
let hijriDate: { day: string; month: { en: string; ar: string }; year: string } | null = null;
4444
try {
45-
const url = `https://api.aladhan.com/v1/timings?latitude=${city.latitude}&longitude=${city.longitude}&method=${city.method}`;
45+
// Use date in URL to avoid 302 redirect issues with caching
46+
const today = new Date()
47+
.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' })
48+
.replace(/\//g, '-');
49+
const url = `https://api.aladhan.com/v1/timings/${today}?latitude=${city.latitude}&longitude=${city.longitude}&method=${city.method}`;
4650
const res = await fetch(url, { next: { revalidate: 3600 } });
4751
const j = await res.json();
4852
if (j.code === 200) {

0 commit comments

Comments
 (0)