Skip to content

Commit

Permalink
Merge pull request #2343 from nextcloud/backport/2339/stable28
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jul 10, 2024
2 parents 6068571 + 226e4d6 commit 1379504
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 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.

17 changes: 10 additions & 7 deletions src/services/WebdavClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ 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() || '',
// Use a method for the headers, to always get the current request token
const getHeaders = () => {
return {
// 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 }
: { headers },
? { username: getToken(), password: '', headers: getHeaders() }
: { headers: getHeaders() },
)

return client
Expand Down

0 comments on commit 1379504

Please sign in to comment.