Skip to content

Commit

Permalink
fix: webdav default headers
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Feb 28, 2024
1 parent d7c057a commit 05644a6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/services/WebdavClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ import { createClient } from 'webdav'
import { getRootPath, getToken, isPublic } from '../utils/davUtils'
import { getRequestToken } from '@nextcloud/auth'

const headers = {
// Add this so the server knows it is an request from the browser
'X-Requested-With': 'XMLHttpRequest',
// Add the request token to the request
requesttoken: getRequestToken() || '',
}

export const getClient = () => {
const client = createClient(getRootPath(), isPublic()
? { username: getToken(), password: '' }
: { headers: { requesttoken: getRequestToken() || '' } },
? { username: getToken(), password: '', headers }
: { headers },
)

return client
}

0 comments on commit 05644a6

Please sign in to comment.