correction faille de securité
All checks were successful
Build and Push App / build (push) Successful in 5m50s
All checks were successful
Build and Push App / build (push) Successful in 5m50s
This commit is contained in:
@@ -77,7 +77,9 @@ const BusinessDetailPage = () => {
|
||||
|
||||
// 2. Try API (Database)
|
||||
try {
|
||||
const res = await fetch(`/api/businesses/${id}`);
|
||||
const res = await fetch(`/api/businesses/${id}`, {
|
||||
headers: user ? { 'x-user-id': user.id } : {}
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setBusiness(data);
|
||||
@@ -104,7 +106,10 @@ const BusinessDetailPage = () => {
|
||||
}
|
||||
|
||||
// Also increment views count in DB (Legacy support)
|
||||
fetch(`/api/businesses/${id}/view`, { method: 'POST' }).catch(console.error);
|
||||
fetch(`/api/businesses/${id}/view`, {
|
||||
method: 'POST',
|
||||
headers: user ? { 'x-user-id': user.id } : {}
|
||||
}).catch(console.error);
|
||||
} else {
|
||||
setBusiness(null);
|
||||
}
|
||||
@@ -135,7 +140,9 @@ const BusinessDetailPage = () => {
|
||||
// 5. Fetch all ratings
|
||||
try {
|
||||
setLoadingRatings(true);
|
||||
const ratingsRes = await fetch(`/api/businesses/${id}/ratings`);
|
||||
const ratingsRes = await fetch(`/api/businesses/${id}/ratings`, {
|
||||
headers: user ? { 'x-user-id': user.id } : {}
|
||||
});
|
||||
if (ratingsRes.ok) {
|
||||
const ratingsData = await ratingsRes.json();
|
||||
setRatings(ratingsData);
|
||||
|
||||
@@ -7,8 +7,10 @@ import { Search, Loader2 } from 'lucide-react';
|
||||
import { Business, Country } from '../../types';
|
||||
import BusinessCard from '../../components/BusinessCard';
|
||||
import AnnuaireHero from '../../components/AnnuaireHero';
|
||||
import { useUser } from '../../components/UserProvider';
|
||||
|
||||
const AnnuairePageContent = () => {
|
||||
const { user } = useUser();
|
||||
const [businesses, setBusinesses] = useState<Business[]>([]);
|
||||
const [featuredBusiness, setFeaturedBusiness] = useState<Business | null>(null);
|
||||
const [countries, setCountries] = useState<Country[]>([]);
|
||||
@@ -41,7 +43,10 @@ const AnnuairePageContent = () => {
|
||||
const fetchHeadliner = async () => {
|
||||
try {
|
||||
// Disable caching to ensure we get fresh data and more variety
|
||||
const res = await fetch('/api/businesses?featured=true', { cache: 'no-store' });
|
||||
const res = await fetch('/api/businesses?featured=true', {
|
||||
cache: 'no-store',
|
||||
headers: user ? { 'x-user-id': user.id } : {}
|
||||
});
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
// Truly random selection from the pool of featured businesses
|
||||
@@ -65,7 +70,9 @@ const AnnuairePageContent = () => {
|
||||
if (filterCountry !== 'All') params.append('countryId', filterCountry);
|
||||
if (searchQuery) params.append('q', searchQuery);
|
||||
|
||||
const res = await fetch(`/api/businesses?${params.toString()}`);
|
||||
const res = await fetch(`/api/businesses?${params.toString()}`, {
|
||||
headers: user ? { 'x-user-id': user.id } : {}
|
||||
});
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) {
|
||||
setBusinesses(data);
|
||||
|
||||
Reference in New Issue
Block a user