diff --git a/src/backend/src/routers/_default.js b/src/backend/src/routers/_default.js index 806ad5d0c..aea40b2d8 100644 --- a/src/backend/src/routers/_default.js +++ b/src/backend/src/routers/_default.js @@ -482,7 +482,7 @@ router.all('*', async function (req, res, next) { //------------------------------------------ else { // replace hostname with static hosting domain and redirect to the same path - return res.redirect(301, `${req.protocol }://${ req.get('host').replace(config.domain, config.static_hosting_domain) }${req.originalUrl}`); + return res.redirect(302, `${req.protocol }://${ req.get('host').replace(config.domain, config.static_hosting_domain) }${req.originalUrl}`); } }); diff --git a/src/backend/src/services/WebDAV/WebDAVService.js b/src/backend/src/services/WebDAV/WebDAVService.js index 3856081f0..9c86db9bb 100644 --- a/src/backend/src/services/WebDAV/WebDAVService.js +++ b/src/backend/src/services/WebDAV/WebDAVService.js @@ -218,9 +218,10 @@ class WebDAVService extends BaseService { } )(); r_webdav.use(xmlparser()); - app.use('/dav', r_webdav); + app.use('/', r_webdav); Endpoint({ + subdomain: 'dav', route: '/*', methods: [ 'PROPFIND', @@ -260,50 +261,6 @@ class WebDAVService extends BaseService { }); }, }).attach( r_webdav); - - const r_rootdav = (() => { - const require = this.require; - const express = require('express'); - return express.Router(); - } )(); - app.use('/', r_rootdav); - Endpoint({ - route: '/*', - methods: [ 'PROPFIND' ], - mw: [ configurable_auth({ optional: true }) ], - /** - * - * @param {import("express").Request} req - * @param {import("express").Response} res - */ - handler: async ( req, res ) => { - const svc_su = this.services.get('su'); - - let actor = await this.handleHttpBasicAuth(req.actor, req, res); - if ( ! actor ) { - return; - } - - if ( req.path !== '/' && !req.path.startsWith('/dav') ) { - return res.status(404).end( 'Not Found'); - } - if ( req.path === '/dav' ) { - svc_su.sudo(actor, async () => { - this.handleWebDavServer('/', req, res); - }); - } - - // Set proper headers for WebDAV XML response - res.set({ - 'Content-Type': 'application/xml; charset=utf-8', - DAV: '1, 2', - 'MS-Author-Via': 'DAV', - }); - - res.status(207); - res.end(ROOT_WEB_DAV_RESPONSE_XML); - }, - }).attach( r_rootdav); } } diff --git a/src/backend/src/services/WebDAV/methodHandlers/COPY.mjs b/src/backend/src/services/WebDAV/methodHandlers/COPY.mjs index a3fab874d..395321811 100644 --- a/src/backend/src/services/WebDAV/methodHandlers/COPY.mjs +++ b/src/backend/src/services/WebDAV/methodHandlers/COPY.mjs @@ -33,7 +33,7 @@ export const COPY = async ( req, res, _filePath, fileNode, headerLockToken ) => res.status(400).end( 'Bad Request: Destination must be within WebDAV namespace'); return; } - destinationPath = destUrl.pathname.substring(4); // Remove '/dav' prefix + destinationPath = destUrl.pathname; if ( ! destinationPath.startsWith('/') ) { destinationPath = `/${destinationPath}`; } diff --git a/src/backend/src/services/WebDAV/methodHandlers/MOVE.mjs b/src/backend/src/services/WebDAV/methodHandlers/MOVE.mjs index e111f5f2a..0f3702466 100644 --- a/src/backend/src/services/WebDAV/methodHandlers/MOVE.mjs +++ b/src/backend/src/services/WebDAV/methodHandlers/MOVE.mjs @@ -34,7 +34,7 @@ export const MOVE = async ( req, res, filePath, fileNode, headerLockToken ) => { res.status(400).end( 'Bad Request: Destination must be within WebDAV namespace'); return; } - destinationPath = destUrl.pathname.slice(4); // Remove '/dav' prefix + destinationPath = destUrl.pathname; // Remove '/dav' prefix if ( ! destinationPath.startsWith('/') ) { destinationPath = `/${destinationPath}`; }