`rel="next"` from the legacy `/query` aliases points at `/api/query`, silently moving clients off the path they requested
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 50/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
Hướng nghiên cứu
Start with routes/compatability.js, controllers/utils.js, and routes/tests/query.test.js, then inspect how req.originalUrl differs from req.baseUrl + req.path for the three aliases. Confirm the chosen link behavior with a POST test, update public/API.html, and ensure the decision is explicit and covered by the test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
/v1/api/getByProperties, /v1/api/query.action, and /v1/api/getByProperties.action are URL rewrites onto /v1/api/query (routes/compatability.js:8-10). Now that #312 gives /query a rel="next" Link, a response to any of those aliases carries a next link naming /v1/api/query rather than the path the client actually requested. A client that walks its pages leaves the legacy path after page 1 and is never told.
Verified on production 2026-09-24, read-only:
POST /v1/api/getByProperties?limit=1 {"type":"Annotation"}
POST /v1/api/query.action?limit=1 {"type":"Annotation"}
POST /v1/api/getByProperties.action?limit=1 {"type":"Annotation"}
-> 200, all three:
Link: <https://store.rerum.io/v1/api/query?limit=1&skip=1>; rel="next"
Why this matters
setNextPageLink() builds the path from req.baseUrl + req.path (controllers/utils.js:155). express-urlrewrite replaces req.url before the router matches, so by the time the /query controller runs those two describe the rewritten route. req.originalUrl is untouched and still holds what the client sent, so the alias is recoverable either way.
Pointing at the canonical path is a defensible thing for rel="next" to do. The problem is that it is currently a side effect of how the rewrite works rather than a decision we made, and it happens silently:
- Nothing in the response says the path changed. There is no
Content-Location, so a client cannot know page 2 lives elsewhere without diffing URLs it did not construct. - The aliases exist because old clients still call them. Those are the clients least likely to survive being handed a path their stack was never set up for — fixed base paths, proxy rules, allowlists.
- Page 1 and page 2 of one walk arrive from two different endpoints, so anything that caches, logs, or rate limits per path sees one walk as two.
Scope is narrow: only paged endpoints are affected, which is /query through its three aliases. The /batch_create -> /bulkCreate rewrite does not page.
Neither the behavior nor the aliases are covered anywhere. routes/__tests__/query.test.js never exercises a rewritten path — __tests__/core_provider_contract.test.js:14 only asserts that compatability.js is mounted — and public/API.html does not mention getByProperties at all.
Proposed change
Decide which of these we mean, then make it explicit in code and in public/API.html.
-
Keep the canonical link and announce it. Serve
Content-Location: /v1/api/queryon responses that arrived through a rewrite, so the move from alias to canonical path is stated rather than inferred. One header, and the current behavior stops being accidental. -
Keep the client on the path it asked for. Build the link from the pathname of
req.originalUrlinstead ofreq.baseUrl + req.path. For every non-rewritten route the two are identical, so nothing else changes. This keeps a legacy walk entirely on the legacy path, at the cost of advertising a deprecated URL in a header we control.
Recommend option 1. The canonical path is the better destination, and the only real complaint is that we currently arrive there without saying so.
Either way, add a case to routes/__tests__/query.test.js that POSTs to /v1/api/getByProperties and asserts the rel="next" path, so the choice cannot drift, and give the aliases a line in public/API.html noting that they are rewrites onto /query and what their next links point at.
- Ngôn ngữ chính
- JavaScript
- Star
- 3
- Fork
- 6
- Merge trung bình
- 14 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CenterForDigitalHumanities/rerum_server_nodejs
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
backend dependencies easy
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
CenterForDigitalHumanities/rerum_server_nodejs#290 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
-
Code Cleanup EpicĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của CenterForDigitalHumanities/rerum_server_nodejs
Issue tương tự
-
Let TypeScript accept an initial object in ReactiveDictCó thể đã có người làm @yograj-vijay-yadav đã nhận hôm nay. Đang mởbug good first issue help wanted workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
meteor/meteor#14919 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
akitaonrails/FrankMD#268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
account: profile
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
mfreed7/xslt_polyfill#65 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày