dav: add requested with header
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/900/head
parent
79c7b02204
commit
4b4e4f2c09
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue