Follow-up to #296, which was resolved by #295. Two small Allow accuracy gaps remain. Both sit outside the scope of #296, which covered only routes that already return a 405.
OPTIONS is never listed in Allow
rest.sendMethodNotAllowed() emits only the verbs registered on the route, so no 405 response advertises OPTIONS. The cors middleware in app.js answers OPTIONS at every path with a 204, even with no Origin header present:
OPTIONS /v1/api/create -> HTTP/1.1 204 No Content
OPTIONS /v1/api/query -> HTTP/1.1 204 No Content
OPTIONS /v1/id/:_id -> HTTP/1.1 204 No Content
RFC 9110 §10.2.1 defines Allow as the set of methods supported by the target resource, so OPTIONS belongs in every value we emit.
Suggested approach: append OPTIONS inside rest.sendMethodNotAllowed() and rest.createPatchOverrideMiddleware() rather than editing all 20 call sites, then update getAllowedMethods() in routes/__tests__/route_wrappers.test.js so the derived expectation still matches.
Single-verb routes 404 where a 405 fits better
These routes register one verb with no .all() fallback, so a wrong method falls through to the app's 404 handler with no Allow header at all.
| Request |
Current |
Expected |
POST /v1/api |
404 |
405 with Allow: GET,HEAD,OPTIONS |
GET /v1/api/accessToken |
404 |
405 with Allow: POST,OPTIONS |
GET /v1/api/refreshToken |
404 |
405 with Allow: POST,OPTIONS |
POST /v1/ |
404 |
405 with Allow: GET,HEAD,OPTIONS |
Sources: router.get('/api', ...) in routes/api-routes.js, /accessToken and /refreshToken in routes/compatability.js, and router.get('/', ...) in routes/static.js.
Worth deciding whether /v1/ is wanted here. That router also serves the static public directory, so an .all() fallback has to sit after the static middleware or it will shadow real files.
Follow-up to #296, which was resolved by #295. Two small
Allowaccuracy gaps remain. Both sit outside the scope of #296, which covered only routes that already return a 405.OPTIONS is never listed in Allow
rest.sendMethodNotAllowed()emits only the verbs registered on the route, so no 405 response advertisesOPTIONS. Thecorsmiddleware inapp.jsanswersOPTIONSat every path with a 204, even with noOriginheader present:RFC 9110 §10.2.1 defines
Allowas the set of methods supported by the target resource, soOPTIONSbelongs in every value we emit.Suggested approach: append
OPTIONSinsiderest.sendMethodNotAllowed()andrest.createPatchOverrideMiddleware()rather than editing all 20 call sites, then updategetAllowedMethods()inroutes/__tests__/route_wrappers.test.jsso the derived expectation still matches.Single-verb routes 404 where a 405 fits better
These routes register one verb with no
.all()fallback, so a wrong method falls through to the app's 404 handler with noAllowheader at all.POST /v1/apiAllow: GET,HEAD,OPTIONSGET /v1/api/accessTokenAllow: POST,OPTIONSGET /v1/api/refreshTokenAllow: POST,OPTIONSPOST /v1/Allow: GET,HEAD,OPTIONSSources:
router.get('/api', ...)inroutes/api-routes.js,/accessTokenand/refreshTokeninroutes/compatability.js, androuter.get('/', ...)inroutes/static.js.Worth deciding whether
/v1/is wanted here. That router also serves the staticpublicdirectory, so an.all()fallback has to sit after the static middleware or it will shadow real files.