Skip to content

Commit ab366b4

Browse files
feat(webdav): configurable mount display name (WEBDAV_NAME)
The WebDAV root now advertises a configurable DAV:displayname (env WEBDAV_NAME, default "OpenCoper") instead of the hard-coded "OpenCoperLock", so Finder / Cyberduck / GNOME label the mount with a short, tidy name. Windows Explorer ignores DAV:displayname and labels the mapped drive from the URL's last path segment, so docs/API.md gains a "Naming the drive" section with the nginx recipe to expose WebDAV under a path ending in the desired name (e.g. /OpenCoper/, using the X-Forwarded-Prefix we already honour). .env.example documents WEBDAV_NAME.
1 parent febf2c3 commit ab366b4

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎.env.example‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ UPDATE_BRANCH=main
9292
GITHUB_TOKEN=
9393
# Set to false where updates are managed externally; disables the one-click update button.
9494
SELF_UPDATE_ENABLED=true
95+
96+
# ── WebDAV ───────────────────────────────────────────────────────────────────
97+
# Name advertised for the WebDAV root. Finder / Cyberduck / GNOME label the mount with this;
98+
# keep it short. (Windows Explorer ignores it and uses the URL's last path segment instead —
99+
# see docs/API.md "Naming the drive on Windows".)
100+
WEBDAV_NAME=OpenCoper

‎apps/api/src/env.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ const envSchema = z.object({
7070
.enum(['true', 'false'])
7171
.default('true')
7272
.transform((v) => v === 'true'),
73+
74+
// Display name advertised for the WebDAV root (DAV:displayname). Clients that honour it
75+
// (Finder, Cyberduck, GNOME…) label the mount with this. Keep it short — some clients (and
76+
// rename fields) truncate long names. NOTE: Windows Explorer ignores this and labels the
77+
// mapped drive from the URL's last path segment instead.
78+
WEBDAV_NAME: z.string().default('OpenCoper'),
7379
});
7480

7581
export type Env = z.infer<typeof envSchema> & { masterKey: Buffer };

‎apps/api/src/routes/webdav.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export const webdavRoutes: FastifyPluginAsync = async (app) => {
192192
};
193193
}
194194
if (node.type === 'root') {
195-
parts.push(propXml(base, [], true, 'OpenCoperLock', 0, new Date(), '', quota));
195+
parts.push(propXml(base, [], true, app.ctx.env.WEBDAV_NAME, 0, new Date(), '', quota));
196196
} else if (node.type === 'folder') {
197197
parts.push(propXml(base, segments, true, node.folder.name, 0, node.folder.createdAt, '', quota));
198198
} else {

‎docs/API.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,36 @@ from there rather than typing it).
121121
> clients that strip `/api` can list the root but fail to open folders. With it, hrefs become
122122
> `/api/dav/…` and navigation works.
123123
124+
### Naming the drive
125+
126+
The name a client shows for the mount depends on the client:
127+
128+
- **Finder / Cyberduck / GNOME** use the server's advertised name. Set `WEBDAV_NAME` in `.env`
129+
(default `OpenCoper`) and reconnect — the mount is labelled with that.
130+
- **Windows Explorer ignores the advertised name** and labels the mapped drive from the **last
131+
segment of the URL** you mounted. So `…/api/dav/` shows up as *“dav (\\host@SSL\DavWWWRoot\…)”*.
132+
To get a custom label like **OpenCoper**, expose WebDAV under a path ending in that word and
133+
mount *that* URL — the server already rewrites hrefs from `X-Forwarded-Prefix`:
134+
135+
```nginx
136+
# Mount https://<host>/OpenCoper/ → Windows labels the drive "OpenCoper"
137+
location /OpenCoper/ {
138+
proxy_pass http://127.0.0.1:4000/dav/; # trailing slash → API sees /dav/
139+
proxy_set_header Host $host;
140+
proxy_set_header Authorization $http_authorization;
141+
proxy_set_header X-Forwarded-Proto $scheme;
142+
proxy_set_header X-Forwarded-Prefix /OpenCoper; # hrefs stay under /OpenCoper
143+
proxy_pass_request_headers on;
144+
client_max_body_size 0;
145+
proxy_request_buffering off;
146+
proxy_buffering off;
147+
proxy_read_timeout 3600s;
148+
}
149+
```
150+
151+
(Or simply map the drive and rename it in *This PC* — but the label above is set once, for
152+
everyone.)
153+
124154
### Diagnosing a mount that won't connect
125155

126156
First prove the server side works, independent of any OS client:

0 commit comments

Comments
 (0)