Skip to content

Develop - #71

Merged
Benevanio merged 2 commits into
masterfrom
develop
Apr 7, 2026
Merged

Benevanio merged 2 commits into
masterfrom
develop

Conversation

@Benevanio

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 7, 2026 15:20
@Benevanio
Benevanio merged commit 4d00d0b into master Apr 7, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in JobAtlas – Kanban Apr 7, 2026
@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
painel-vagas Ready Ready Preview, Comment Apr 7, 2026 3:20pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Vercel rewrite for /api/* calls and hardens the frontend API client to surface readable errors when the backend/proxy returns non-JSON responses.

Changes:

  • Added vercel.json rewrite to proxy /api/(.*) to the VPS API endpoint.
  • Introduced readPayload() in jobsService to gracefully read JSON or text payloads.
  • Added a unit test covering non-JSON error responses for fetchKeywords().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
vercel.json Adds a Vercel rewrite to forward /api/* requests to the backend host.
frontend/src/services/jobsService.ts Centralizes response parsing to support non-JSON bodies and improve thrown error messages.
frontend/tests/unit/utils/jobsService.test.ts Adds coverage for non-JSON error payloads from the API/proxy layer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +39
if (!contentType || contentType.includes("application/json")) {
try {
const payload = await response.json();
return payload && typeof payload === "object" ? (payload as Record<string, unknown>) : {};
} catch {
// Fallback below for non-JSON bodies returned by proxies/platforms.
}
}

if (typeof response.text === "function") {
const text = await response.text();
return text ? { message: text } : {};
}

return {};

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readPayload tenta fazer response.json() quando o content-type está vazio e, se o parse falhar, faz fallback para response.text(). Em fetch, ler o body via json() consome o stream; após uma exceção de parse normalmente não é possível ler o body novamente, então o fallback tende a não funcionar. Sugestão: ler o body uma única vez via text() e então fazer JSON.parse quando apropriado, ou usar response.clone() antes de tentar json() para preservar o body para o fallback.

Suggested change
if (!contentType || contentType.includes("application/json")) {
try {
const payload = await response.json();
return payload && typeof payload === "object" ? (payload as Record<string, unknown>) : {};
} catch {
// Fallback below for non-JSON bodies returned by proxies/platforms.
}
}
if (typeof response.text === "function") {
const text = await response.text();
return text ? { message: text } : {};
}
return {};
if (typeof response.text !== "function") {
return {};
}
const text = await response.text();
if (!text) {
return {};
}
if (!contentType || contentType.includes("application/json")) {
try {
const payload = JSON.parse(text);
return payload && typeof payload === "object" ? (payload as Record<string, unknown>) : {};
} catch {
// Fallback below for non-JSON bodies returned by proxies/platforms.
}
}
return { message: text };

Copilot uses AI. Check for mistakes.
Comment thread vercel.json
"rewrites": [
{
"source": "/api/(.*)",
"destination": "http://jobsglobalscraper.ddns.net/api/$1"

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O rewrite está apontando para um destino http:// (sem TLS). Isso expõe tráfego em texto claro entre a infraestrutura da Vercel e o backend; se o backend suporta HTTPS, prefira https://... (ou outra solução de proxy seguro).

Suggested change
"destination": "http://jobsglobalscraper.ddns.net/api/$1"
"destination": "https://jobsglobalscraper.ddns.net/api/$1"

Copilot uses AI. Check for mistakes.
Comment thread vercel.json
Comment on lines +1 to +8
{
"rewrites": [
{
"source": "/api/(.*)",
"destination": "http://jobsglobalscraper.ddns.net/api/$1"
}
]
}

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Já existe um frontend/vercel.json com o mesmo conteúdo. Manter duas configs de Vercel em locais diferentes tende a causar drift/confusão sobre qual arquivo é efetivamente usado (depende do Root Directory configurado no projeto Vercel). Sugestão: consolidar em um único local e remover o duplicado, ou documentar explicitamente qual diretório é o root do deploy.

Copilot uses AI. Check for mistakes.

This branch was previously deployed

1 inactive deployment
Preview — b1089839 Deployed Apr 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants