Skip to content

🐛 enforce https in requestForBatchFetch for SSR fetch paths - #40562

Open
mrdevel2002-ui wants to merge 2 commits into
ampproject:mainfrom
mrdevel2002-ui:batched-json-ssr-https
Open

mrdevel2002-ui wants to merge 2 commits into
ampproject:mainfrom
mrdevel2002-ui:batched-json-ssr-https

Conversation

@mrdevel2002-ui

Copy link
Copy Markdown

batchFetchJsonFor asserts assertHttpsUrl on the fetch URL, but the shared requestForBatchFetch helper does not, and amp-list (ssrTemplate_) and amp-autocomplete (getRemoteData_) call it directly on their viewer/SSR path. In SSR mode a non-https src is then built into a credentialed request and handed to the viewer to fetch, while the inline (non-SSR) path rejects it. Moving the check into requestForBatchFetch closes that gap for both SSR callers.

Added a regression test in test-batched-json.js that exercises requestForBatchFetch directly.

batchFetchJsonFor asserted assertHttpsUrl on the fetch URL but the shared requestForBatchFetch helper did not, so the amp-list and amp-autocomplete SSR paths that call it directly fetched a non-https src that the inline path rejects. Move the check into requestForBatchFetch so every fetch path enforces it.
Throwing synchronously escaped amp-list's fetchList_ error handling on the
SSR path and broke the amp-state:/amp-script: SSR unit tests. Keep the
original synchronous check in batchFetchJsonFor.
@mrdevel2002-ui

Copy link
Copy Markdown
Author

Pushed a fix for the All Unit Tests failure. The https check in requestForBatchFetch now rejects the returned promise instead of throwing, so amp-list's SSR path hands it to its normal fetch-error handling. batchFetchJsonFor keeps its original synchronous assert.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant