Skip to content

Commit 38a3432

Browse files
Jeremias Santosclaude
authored andcommitted
fix(pav-55): adicionar credentials: include nas chamadas fetch do jobsService
Corrige erro 401 em rotas protegidas para usuarios autenticados, adicionando credentials: "include" em todas as chamadas fetch para que o cookie de sessao (vagas_session) seja enviado nas requests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ad8b76c commit 38a3432

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

frontend/src/services/jobsService.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ function readMessage(payload: unknown): string | undefined {
5858
}
5959

6060
export async function fetchJobFiles(): Promise<JobFile[]> {
61-
const response = await fetch(buildApiUrl("/api/jobs/files"));
61+
const response = await fetch(buildApiUrl("/api/jobs/files"), {
62+
credentials: "include",
63+
});
6264
const payload = (await readPayload(response)) as { files?: unknown } & Record<
6365
string,
6466
unknown
@@ -86,7 +88,9 @@ export async function fetchJobFiles(): Promise<JobFile[]> {
8688

8789
export async function fetchJobsByFile(fileName: string): Promise<JobsResponse> {
8890
const suffix = fileName ? `?file=${encodeURIComponent(fileName)}` : "";
89-
const response = await fetch(buildApiUrl(`/api/jobs${suffix}`));
91+
const response = await fetch(buildApiUrl(`/api/jobs${suffix}`), {
92+
credentials: "include",
93+
});
9094
const payload = (await readPayload(response)) as Record<string, unknown>;
9195

9296
if (!response.ok) {
@@ -106,7 +110,9 @@ export async function fetchJobsByFile(fileName: string): Promise<JobsResponse> {
106110
}
107111

108112
export async function fetchKeywords(): Promise<string[]> {
109-
const response = await fetch(buildApiUrl("/api/keywords"));
113+
const response = await fetch(buildApiUrl("/api/keywords"), {
114+
credentials: "include",
115+
});
110116
const payload = (await readPayload(response)) as {
111117
keywords?: unknown;
112118
} & Record<string, unknown>;
@@ -125,6 +131,7 @@ export async function saveKeywords(keywords: string[]): Promise<void> {
125131
"Content-Type": "application/json",
126132
},
127133
body: JSON.stringify({ keywords }),
134+
credentials: "include",
128135
});
129136
const payload = (await readPayload(response)) as Record<string, unknown>;
130137

@@ -136,6 +143,7 @@ export async function saveKeywords(keywords: string[]): Promise<void> {
136143
export async function runScraperRequest(): Promise<void> {
137144
const response = await fetch(buildApiUrl("/api/jobs/search"), {
138145
method: "POST",
146+
credentials: "include",
139147
});
140148
const payload = (await readPayload(response)) as Record<string, unknown>;
141149

0 commit comments

Comments
 (0)