fix: add API proxy via Next rewrites + fix hardcoded localhost URLs

This commit is contained in:
Erik Silva
2025-12-09 02:17:00 -03:00
parent 86e4afb916
commit 773172c63c
2 changed files with 13 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ export default function ConfiguracoesPage() {
} }
// Buscar dados da API // Buscar dados da API
const response = await fetch('http://localhost:8080/api/agency/profile', { const response = await fetch('/api/agency/profile', {
headers: { headers: {
'Authorization': `Bearer ${token}`, 'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -156,7 +156,7 @@ export default function ConfiguracoesPage() {
return; return;
} }
const response = await fetch('http://localhost:8080/api/agency/profile', { const response = await fetch('/api/agency/profile', {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Authorization': `Bearer ${token}`, 'Authorization': `Bearer ${token}`,
@@ -224,7 +224,7 @@ export default function ConfiguracoesPage() {
return; return;
} }
const response = await fetch('http://localhost:8080/api/auth/change-password', { const response = await fetch('/api/auth/change-password', {
method: 'POST', method: 'POST',
headers: { headers: {
'Authorization': `Bearer ${token}`, 'Authorization': `Bearer ${token}`,

View File

@@ -4,6 +4,16 @@ const nextConfig: NextConfig = {
experimental: { experimental: {
externalDir: true, externalDir: true,
}, },
async rewrites() {
return {
beforeFiles: [
{
source: "/api/:path*",
destination: "http://backend:8080/api/:path*",
},
],
};
},
}; };
export default nextConfig; export default nextConfig;