mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
Move webdav to dav.puter.com
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
This commit is contained in:
committed by
Neal Shah
parent
404a5e9050
commit
bbe1242eff
@@ -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}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user