fix(verified-reviews): send a JSON content-type to the reviews API
MA
1mo ago+10+10+01234567890123456789-4-4-0123456789
Problem
Verified Reviews loaders return no rating and no reviews. POST https://awsapis3.netreviews.eu/product now rejects the content-type a string body defaults to:
| content-type | status |
|---|---|
application/json | 200 |
text/plain;charset=UTF-8 (fetch default for a string body) | 502 |
| none | 415 FST_ERR_CTP_INVALID_MEDIA_TYPE |
createClient sends no content-type, so rating, ratings and reviews fail. On deploy the catches swallow the error and return empty data, and console.error does not reach OTel, so nothing surfaces.
Change
verified-reviews/utils/client.ts: the 3 POSTs sendcontent-type: application/json.- The
context.isDeploybranches log throughlogger.error(with the HttpError) instead ofconsole.error. ThefullReviewcatch now uses its own label instead of theratingsone.
Verification
- Same payload, before:
HttpError 502. After: ratings and reviews returned (28 reviews, weighted rating 4.5 on a product group). - Forced
isDeploywith atext/plainbody: the failure is logged throughlogger.errorand an empty result is returned without throwing. - Verified end to end on a VTEX storefront product page (reviews sheet and JSON-LD
aggregateRatingrestored). deno fmt --checkanddeno check verified-reviews/mod.tspass.
🤖 Generated with Claude Code
Summary by cubic
Fixes Verified Reviews requests to the Netreviews product API by sending content-type: application/json, so ratings and reviews load again instead of failing with a 502. Deploy-side errors now go through logger.error so they surface in OTel instead of disappearing via console.error.
Summary by CodeRabbit
- Bug Fixes
- Fixed Verified Reviews requests that could fail with 502 responses by correctly identifying JSON request bodies.
- Improved error reporting during deployment by routing errors through the application logger.