Registry / web-framework / webdav-server

webdav-server

JSON →
library2.6.2jsnpmunverified

webdav-server is a robust and highly configurable WebDAV server implementation for Node.js, currently stable at version 2.6.2. It allows developers to create a WebDAV endpoint capable of serving various types of resources, including physical files and folders from a hard drive, in-memory virtual resources, dynamically processed/computed content, and entirely custom resource types, all within a single server instance. The project maintains an active release cadence with frequent updates, as seen with multiple patch and minor releases since its major version 2.0.0. Key differentiators include its flexible architecture that supports custom user managers, resource types, HTTP methods, and server state persistence, making it suitable for diverse applications from human-readable content management via WebDAV clients to inter-program information sharing with temporary file systems. It adheres strictly to RFC4918.

npm install webdav-server
INSTALL
IMPORT
SIG · WEBDAV-SERVER
W
webdav-server
web-frameworkjavascriptv2.6.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebDAVServer
import { WebDAVServer } from 'webdav-server'
const WebDAVServer = require('webdav-server')
Primary class for creating a WebDAV server instance. While CommonJS `require` might still work, `import` is the idiomatic way, especially with TypeScript and modern Node.js development.
PhysicalFileSystem
import { PhysicalFileSystem } from 'webdav-server'
import PhysicalFileSystem from 'webdav-server/lib/manager/PhysicalFileSystem'
Used to mount a file system directly from a physical path on the disk. Ensure correct path resolution and permissions for the specified root directory.
VirtualFileSystem
import { VirtualFileSystem } from 'webdav-server'
import * as VFS from 'webdav-server/virtual'
Provides an in-memory file system for temporary or programmatic resource management, ideal for testing or ephemeral data without disk persistence.
WebDAVServerOptions
import { WebDAVServerOptions } from 'webdav-server'
TypeScript type for configuring the WebDAV server. Use it to define server port, authentication, debug mode, and other settings.

This quickstart demonstrates how to set up a basic WebDAV server with a physical file system mounted at `/physical`, listening on port 8080, and includes graceful shutdown.

import { WebDAVServer, PhysicalFileSystem } from 'webdav-server'; import * as http from 'http'; import * as path from 'path'; // Define the port for the WebDAV server const port = 8080; // Define the root directory for the physical file system // For a production environment, use a robust path resolution method const physicalRootPath = path.resolve(__dirname, 'webdav-root'); // Create a new WebDAV server instance const server = new WebDAVServer({ port: port, // debug: true, // Uncomment for detailed logging // Set the server name and version for HTTP headers serverName: 'My WebDAV Server', version: '1.0.0' }); // Configure a physical file system at the root '/physical' of the WebDAV server // This maps the physicalRootPath to the WebDAV path. server.setFileSystem('/physical', new PhysicalFileSystem(physicalRootPath)); // Alternatively, for a virtual file system: // server.setFileSystem('/virtual', new VirtualFileSystem()); // Start the HTTP server to listen for WebDAV requests server.start((s: http.Server) => { console.log(`WebDAV server is listening on http://localhost:${port}`); console.log(`Serving physical files from: ${physicalRootPath}`); console.log('You can now connect with a WebDAV client (e.g., Cyberduck, Windows Network Drive).'); console.log('Example: Connect to http://localhost:8080/physical'); }); // Graceful shutdown process.on('SIGINT', () => { console.log('\nStopping WebDAV server...'); server.stop(() => { console.log('WebDAV server stopped.'); process.exit(0); }); });
Debug
Known issues
breakingVersion 2.0.0 introduced significant internal changes and API modifications. Specifically, the `RequestContext` class properties and how `PROPPATCH` attributes are handled were updated, potentially breaking existing implementations that relied on version 1.x APIs.
fix
Review the official changelog and examples for version 2.x to adapt your codebase. Pay close attention to how request bodies are accessed and how custom properties are managed.
affects: >=2.0.0
gotchaDeploying a `WebDAVServer` with `PhysicalFileSystem` without implementing custom authentication, authorization, or robust path validation can expose your server to unauthorized access and potential data breaches.
fix
Implement custom user managers and authentication/authorization middleware using `server.beforeRequest` or `server.afterRequest` hooks. Carefully validate paths and permissions for all operations on physical resources.
affects: >=1.0.0
gotchaThe `PhysicalFileSystem` constructor takes a root path. Using relative paths (e.g., `'.'`) can lead to unexpected behavior depending on the process's current working directory. Misconfigured paths can also lead to unintended directory exposure.
fix
Always provide an absolute path to `PhysicalFileSystem`, ideally resolved using `path.resolve(__dirname, 'your_data_folder')` to ensure consistency and prevent directory traversal vulnerabilities.
affects: >=1.0.0
gotchaThe default configuration of `webdav-server` does not include any authentication or authorization mechanisms. Without these, anyone can access and modify resources on your WebDAV server.
fix
Implement an authentication manager using `server.setUserManager()` and apply authorization logic within your custom resource definitions or through middleware hooks provided by the server.
affects: >=1.0.0
deprecatedThe `strictMode` option (introduced in v1.6.0) can affect client compatibility. While offering flexibility, deviating from strict RFC4918 compliance might cause issues with some WebDAV clients.
fix
If encountering client compatibility issues, try adjusting the `strictMode` option or reviewing its impact on specific WebDAV methods. Consult client documentation for expected server behavior.
affects: >=1.6.0
Errors
Common errors & fixes
Error: listen EADDRINUSE: address already in use :::8080
The network port configured for the WebDAV server (e.g., 8080) is currently occupied by another application or a previous server instance that was not properly shut down.
fix
Change the `port` option when creating your `WebDAVServer` instance to an available port (e.g., 8081), or identify and terminate the process currently using the desired port.
TypeError: Path must be a string. Received undefined (at ... PhysicalFileSystem.constructor)
The `PhysicalFileSystem` was initialized with an `undefined` or non-string path, typically due to an unhandled variable or incorrect path resolution logic.
fix
Ensure that the root path provided to `new PhysicalFileSystem()` is always a valid, absolute string. Use `path.resolve(__dirname, 'your-webdav-root')` to guarantee an absolute path.
HTTP/1.1 405 Method Not Allowed (from client side)
A WebDAV client is attempting an operation (e.g., PROPFIND, PUT, DELETE) that is not permitted for the requested resource or due to the server's access control configuration. This often indicates a missing privilege, incorrect resource type, or misconfigured method support.
fix
Verify that your `UserManager` and `PrivilegeManager` (if implemented) grant the necessary permissions. Ensure the target resource correctly implements the desired WebDAV methods. Check if the client is expecting a file when it's a folder, or vice-versa.
Upgrade
Version history
2.6.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources