fix: avoid caching project listings
This commit is contained in:
@@ -112,12 +112,20 @@ export default function Home() {
|
|||||||
|
|
||||||
const fetchProjects = async () => {
|
const fetchProjects = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/projects?status=published&take=3', { signal: controller.signal });
|
const response = await fetch('/api/projects?status=published&take=3', {
|
||||||
|
method: 'GET',
|
||||||
|
cache: 'no-store',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Falha ao buscar projetos mais recentes');
|
throw new Error(`Falha ao buscar projetos mais recentes (status ${response.status})`);
|
||||||
}
|
}
|
||||||
const data: PortfolioProject[] = await response.json();
|
|
||||||
if (isMounted) {
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (isMounted && Array.isArray(data)) {
|
||||||
setLatestProjects(data);
|
setLatestProjects(data);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -31,12 +31,20 @@ export default function ProjetosPage() {
|
|||||||
|
|
||||||
const fetchProjects = async () => {
|
const fetchProjects = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/projects?status=published', { signal: controller.signal });
|
const response = await fetch('/api/projects?status=published', {
|
||||||
|
method: 'GET',
|
||||||
|
cache: 'no-store',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Falha ao buscar projetos');
|
throw new Error(`Falha ao buscar projetos (status ${response.status})`);
|
||||||
}
|
}
|
||||||
const data: Project[] = await response.json();
|
|
||||||
if (isMounted) {
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (isMounted && Array.isArray(data)) {
|
||||||
setProjects(data);
|
setProjects(data);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user