mikser-io 11.5.0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io",
3
- "version": "11.5.0",
3
+ "version": "11.6.0",
4
4
  "files": [
5
5
  "app.js",
6
6
  "index.js",
package/src/routes.js CHANGED
@@ -87,6 +87,18 @@ export function routeFor(requestPath) {
87
87
  // facade must disable buffering for it (Caddy
88
88
  // flush_interval -1, nginx proxy_buffering off).
89
89
  // Default false.
90
+ // cors `false` to emit no CORS headers for this mount. The
91
+ // same word as the global `--no-cors` /
92
+ // `config.server.cors: false`, meaning the same thing,
93
+ // scoped to one route. Default undefined — inherit the
94
+ // global setting.
95
+ //
96
+ // For a mount whose clients are not browsers: an OS
97
+ // WebDAV redirector, a CLI tool and curl never consult
98
+ // CORS, so a header naming who may read the endpoint
99
+ // from a web page is a claim with no beneficiary — and
100
+ // on an authenticated endpoint it is better made
101
+ // deliberately than inherited.
90
102
  // methods the HTTP verbs this mount actually serves. Two
91
103
  // consequences, and the second one is load-bearing:
92
104
  // CORS advertises these for the route instead of a
@@ -125,6 +137,7 @@ export function registerRoute({
125
137
  reachability = 'public',
126
138
  streaming = false,
127
139
  methods = null,
140
+ cors,
128
141
  label,
129
142
  detail,
130
143
  displayPath,
@@ -142,8 +155,13 @@ export function registerRoute({
142
155
  throw new Error('registerRoute: `methods` must be an array of verb strings')
143
156
  }
144
157
 
158
+ if (cors !== undefined && cors !== false) {
159
+ throw new Error('registerRoute: `cors` accepts only false — omit it to inherit the global setting')
160
+ }
161
+
145
162
  const descriptor = { path, plugin, reachability, streaming }
146
163
  if (methods) descriptor.methods = methods.map(m => m.toUpperCase())
164
+ if (cors === false) descriptor.cors = false
147
165
 
148
166
  // Dedup by path — a re-register (same path) replaces rather than
149
167
  // duplicates. Mounts happen once per process, but this keeps the
package/src/server.js CHANGED
@@ -249,6 +249,22 @@ export function setupServer() {
249
249
  // PROPFIND, LOCK and the rest.
250
250
  const ownsPreflight = Boolean(route?.methods?.includes('OPTIONS'))
251
251
 
252
+ // A route that wants no CORS headers at all.
253
+ //
254
+ // `origin: false` is the cors package's way of emitting none — the
255
+ // same thing --no-cors asks for globally, scoped to one mount.
256
+ //
257
+ // It needs no preflightContinue, and passing one here was dead
258
+ // code: with a falsy origin the package never builds an
259
+ // originCallback, so it calls next() and does not touch the
260
+ // response at all (cors/lib/index.js:210-228). The mount's own
261
+ // OPTIONS is therefore reached whatever preflightContinue says —
262
+ // which is why removing it changed no test, and why the comment
263
+ // that used to claim otherwise was wrong.
264
+ if (route?.cors === false) {
265
+ return callback(null, { origin: false })
266
+ }
267
+
252
268
  callback(null, {
253
269
  origin: configured === true ? '*' : String(configured),
254
270
  // The verbs the mount actually serves, when it said. A fixed