dav: add requested with header

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/900/head
Varun Patil 2023-10-30 10:58:48 -07:00
parent 79c7b02204
commit 4b4e4f2c09
1 changed files with 6 additions and 3 deletions

View File

@ -29,15 +29,18 @@ const remote = generateRemoteUrl('dav');
const client = createClient(remote); const client = createClient(remote);
// set CSRF token header // set CSRF token header
function setToken(token: string | null) { function setHeaders(token: string | null) {
client.setHeaders({ client.setHeaders({
// Add this so the server knows it is an request from the browser
'X-Requested-With': 'XMLHttpRequest',
// Inject user auth
requesttoken: token ?? String(), requesttoken: token ?? String(),
}); });
} }
// refresh headers when request token changes // refresh headers when request token changes
setToken(getRequestToken()); setHeaders(getRequestToken());
onRequestTokenUpdate((t) => setToken(t)); onRequestTokenUpdate((t) => setHeaders(t));
// Filenames start with this path // Filenames start with this path
export const remotePath = new URL(remote).pathname; export const remotePath = new URL(remote).pathname;