Repository navigation
Conversation
[Medium impact] The change reaches forms that use the built-in location data source. Fix the port rewrite before merging so paged location lists work through standard HTTPS addresses.
|
| url.host = window.location.host; | ||
| url.protocol = window.location.protocol; |
There was a problem hiding this comment.
Next links keep backend ports. Assigning
url.host does not clear the old port when window.location.host has no port. For a page at https://clinic.example, the next link used in the test becomes https://clinic.example:8443/..., not the browser's origin. The second request bypasses the intended proxy and can fail, leaving the dropdown empty. Explicitly copy window.location.port, including its empty value, after changing the protocol.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/datasources/location-data-source.ts
Line: 48-49
Comment:
**Next links keep backend ports.** Assigning `url.host` does not clear the old port when `window.location.host` has no port. For a page at `https://clinic.example`, the next link used in the test becomes `https://clinic.example:8443/...`, not the browser's origin. The second request bypasses the intended proxy and can fail, leaving the dropdown empty. Explicitly copy `window.location.port`, including its empty value, after changing the protocol.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Good catch, thanks. Fixed in 63c2189: the next link's path and query are now resolved against window.location.origin, so the backend's host, port and scheme are all dropped, and a new test on a port-less https://clinic.example page covers it.
|
@mherman22 openmrs/openmrs-esm-core#2019 just merged. It adds |
Requirements
Summary
LocationDataSource.fetchDatamade one request and returneddata.results, so a location list only ever held the first page of results. A form with more tagged locations than the REST page size (webservices.rest.maxResultsDefault, 50 by default) silently drops the rest from the dropdown, for example alocation_datasourcequestion filtered to Visit Location.The list and search branch now calls the framework's
openmrsFetchAll(added in O3-6343) and returnsresponse.data.results.openmrsFetchAllfollows the response'snextlinks until there are none, and requests each later page on the first request's origin with only the link's path and query, so a link naming the backend's host, port or scheme still goes through the frontend proxy. It rejects if any page fails, or if the server repeats a next link.The
uuidbranch offetchDatakeeps its single request.Screenshots
No UI change; the dropdown just lists every location.
Related Issue
None yet. Happy to create an O3 ticket if you'd like one for this.
Other
Tests:
location-data-source.test.tsserves a two-page response and expects all 57 locations, the second request on the page's origin (main returns only the first 50).location-data-source.origin.test.tsruns on a port-lesshttps://clinic.examplepage with a next link fromhttp://backend:8080, and expects the second request athttps://clinic.example/openmrs/ws/rest/v1/location?..., nothttps://clinic.example:8080/....The framework's test mock wraps the real
openmrsFetchAllaround the mockedopenmrsFetch, so these tests still check every request the data source makes. ReplacingopenmrsFetchAllwithopenmrsFetchfails the first two.src/datasourcespasses 12 of 12, andtscis clean.Also checked against a running OpenMRS through its gateway on
http://localhost:8402, with the realopenmrsFetchAllandwebservices.rest.maxResultsDefaultlowered to 2. The server's next links namedhttp://localhost(port 80, unreachable), so the origin handling was exercised too:fetchData(null)fetchData(null, { tag: 'Visit Location' })fetchData('Dashboard')Every request after the first went to
http://localhost:8402/openmrs/ws/rest/v1/location?...&startIndex=N, the next link's path and query on the page's origin.openmrsFetchAllis in the framework's 11.0.1 pre-releases, which this repo already resolves; the11.xpeer range is unchanged.Not changed here: the other data sources (provider, encounter role, the base class) also read only the first page, so on an instance with more records than the page size their dropdowns still list only the first page, as on main.