Skip to content

Commit bfe5775

Browse files
committed
fix: send X-Requested-With header to pass backend CSRF check
1 parent 49df424 commit bfe5775

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/api/axios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;
55
export const api = axios.create({
66
baseURL: API_BASE_URL,
77
withCredentials: true,
8+
headers: { "X-Requested-With": "XMLHttpRequest" },
89
});
910

1011
export const apiClient = api;

src/lib/auth/tokenStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export const tokenStore = {
9595
const response = await fetch(`${API_URL}/api/auth/refresh`, {
9696
method: "POST",
9797
credentials: "include",
98-
headers: { "Content-Type": "application/json" },
98+
headers: {
99+
"Content-Type": "application/json",
100+
"X-Requested-With": "XMLHttpRequest",
101+
},
99102
body: JSON.stringify(token ? { refreshToken: token } : {}),
100103
});
101104

0 commit comments

Comments
 (0)