Skip to content

fix(sap-commerce-cloud): skip prepending apiEndpoint for absolute image URLs#10672

Open
Mihai (Mihai-Sprinceana) wants to merge 1 commit intocontentful:masterfrom
Mihai-Sprinceana:fix/sap-image-url-domain
Open

fix(sap-commerce-cloud): skip prepending apiEndpoint for absolute image URLs#10672
Mihai (Mihai-Sprinceana) wants to merge 1 commit intocontentful:masterfrom
Mihai-Sprinceana:fix/sap-image-url-domain

Conversation

@Mihai-Sprinceana

Summary

Fixes #10235

  • In productTransformer and productDetailsTransformer, the apiEndpoint was unconditionally prepended to any non-empty imageUrl.
  • When the SAP Commerce Cloud API returns images with absolute URLs (e.g. https://static.test.com/media/123), this produced malformed URLs like https://api.test.com/https://static.test.com/media/123.
  • Added a guard so apiEndpoint is only prepended when the image URL is a relative path (does not start with http:// or https://).

Changes

  • apps/sap-commerce-cloud/frontend/src/api/dataTransformers.ts: updated the imageUrl condition in both productTransformer and productDetailsTransformer.

Test plan

  • Verify images with relative URLs (e.g. /media/123) still resolve correctly by prepending apiEndpoint
  • Verify images with absolute URLs (e.g. https://static.test.com/media/123) are passed through unchanged
  • Run existing unit tests: npm run test in apps/sap-commerce-cloud/frontend
  • Add/update unit tests in dataTransformers.test.ts to cover both cases

🤖 Generated with Claude Code

…ge URLs

When the SAP Commerce Cloud API returns images with full absolute URLs
(e.g. https://static.test.com/media/123), the transformer was blindly
prepending the apiEndpoint, producing a malformed URL such as
https://api.test.com/https://static.test.com/media/123.

Guard both productTransformer and productDetailsTransformer so that
apiEndpoint is only prepended when the imageUrl is a relative path.

Fixes contentful#10235

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Mihai-Sprinceana Mihai (Mihai-Sprinceana) marked this pull request as ready for review March 5, 2026 12:10
@Mihai-Sprinceana Mihai (Mihai-Sprinceana) requested a review from a team as a code owner March 5, 2026 12:10
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.

Image Url Domain

1 participant