Skip to content

Commit

Permalink
Merge pull request #849 from nextcloud-libraries/enh/allow-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Dec 21, 2023
2 parents 2351742 + fc5ab15 commit 8c8b725
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/dav/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ export const davRemoteURL = generateRemoteUrl('dav')
* Get a WebDAV client configured to include the Nextcloud request token
*
* @param remoteURL The DAV server remote URL
* @param headers Optional additional headers to set for every request
*/
export const davGetClient = function(remoteURL = davRemoteURL) {
const client = createClient(remoteURL)
export const davGetClient = function(remoteURL = davRemoteURL, headers: Record<string, string> = {}) {
const client = createClient(remoteURL, { headers })

/**
* Set headers for DAV requests
* @param token CSRF token
*/
function setHeaders(token: string | null) {
client.setHeaders({
...headers,
// Add this so the server knows it is an request from the browser
'X-Requested-With': 'XMLHttpRequest',
// Inject user auth
Expand Down

0 comments on commit 8c8b725

Please sign in to comment.