Skip to content

Commit db5da22

Browse files
skjnldsvnextcloud-command
authored andcommitted
fix: webdav default headers
Signed-off-by: skjnldsv <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent d7c057a commit db5da22

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

js/viewer-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/WebdavClient.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ import { createClient } from 'webdav'
2424
import { getRootPath, getToken, isPublic } from '../utils/davUtils'
2525
import { getRequestToken } from '@nextcloud/auth'
2626

27+
const headers = {
28+
// Add this so the server knows it is an request from the browser
29+
'X-Requested-With': 'XMLHttpRequest',
30+
// Add the request token to the request
31+
requesttoken: getRequestToken() || '',
32+
}
33+
2734
export const getClient = () => {
2835
const client = createClient(getRootPath(), isPublic()
29-
? { username: getToken(), password: '' }
30-
: { headers: { requesttoken: getRequestToken() || '' } },
36+
? { username: getToken(), password: '', headers }
37+
: { headers },
3138
)
39+
3240
return client
3341
}

0 commit comments

Comments
 (0)