Skip to content

Commit

Permalink
dav: add requested with header
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Oct 30, 2023
1 parent 79c7b02 commit 4b4e4f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/services/dav/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ const remote = generateRemoteUrl('dav');
const client = createClient(remote);

// set CSRF token header
function setToken(token: string | null) {
function setHeaders(token: string | null) {
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(),
});
}

// refresh headers when request token changes
setToken(getRequestToken());
onRequestTokenUpdate((t) => setToken(t));
setHeaders(getRequestToken());
onRequestTokenUpdate((t) => setHeaders(t));

// Filenames start with this path
export const remotePath = new URL(remote).pathname;
Expand Down

0 comments on commit 4b4e4f2

Please sign in to comment.