Skip to content

fix: Nuvemshop product images (CDN sizes) and default sort first - #633

Merged
JonasJesus42 merged 2 commits into
mainfrom
JonasJesus42/nuvemshop-image-cdn
Oct 7, 2026
Merged

JonasJesus42 merged 2 commits into
mainfrom
JonasJesus42/nuvemshop-image-cdn

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What

getOptimizedMediaUrl gets a native path for Nuvemshop product images, alongside the existing VTEX and Shopify ones.

Why

The deco image proxy (assets.decocms.com/image) answers 403 for dcdn-us.mitiendanube.com. As a result, every product image on a Nuvemshop storefront rendered as broken. I found this while running a TanStack site on @decocms/apps-nuvemshop.

Nuvemshop's CDN only serves fixed sizes, chosen by a filename suffix:

  • -50-0, -100-0, -240-0, -320-0, -480-0 and -640-0;
  • -1024-1024, which is the 1000px original.

Any other size answers 403; I checked each size against the live CDN. The optimizer now picks the smallest size that covers the requested width, falling back to -1024-1024, and keeps the file extension. Non-product URLs on the same host keep going through the default path.

Verified

3 new tests; @decocms/blocks has 906 tests passing and tsc is clean. The biome errors in these two files were already on main (whole-file format drift plus an existing useAltText). The added lines follow the file's existing style, and I did not reformat the files.

🤖 Generated with Claude Code


Summary by cubic

Fixes two Nuvemshop storefront issues: product images returned 403 through the deco image proxy, and a sort select without ?sort_by= showed "Mais vendidos" instead of the real default order.

  • Serves product images from Nuvemshop's own CDN, choosing the smallest fixed-size suffix that covers the requested width (-50-0…-640-0, else -1024-1024) and keeping the extension; non-product URLs still use the default path.
  • Lists the category's configured defaultSort first so the UI matches the actual listing order.
  • Adds 4 tests covering size selection, extension preservation, fallback, and sort ordering.

Written for commit c3472e2. Summary will update on new commits.

Review in cubic Turn on auto-fix

The deco image proxy answers 403 for dcdn-us.mitiendanube.com, so every
Nuvemshop product image rendered broken. Like VTEX and Shopify, rewrite the
URL to the platform CDN's native resize instead: Nuvemshop serves only fixed
sizes picked by a filename suffix (-50/100/240/320/480/640-0, -1024-1024;
anything else 403s), so pick the smallest one that covers the width.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@JonasJesus42
JonasJesus42 requested a review from a team October 7, 2026 01:53
A sort select with no ?sort_by= falls back to its first option, which showed
'Mais vendidos' while the list was actually newest-first (defaultSort).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@JonasJesus42 JonasJesus42 changed the title fix(blocks): serve Nuvemshop product images from its own CDN sizes fix: Nuvemshop product images (CDN sizes) and default sort first Oct 7, 2026
@JonasJesus42

Copy link
Copy Markdown
Contributor Author

Also included: apps-nuvemshop PLP now lists the category's default sort (defaultSort) first. A sort select with no ?sort_by= falls back to its first option, so it showed 'Mais vendidos' while the list was actually newest-first. Test added; 104 tests pass.

@JonasJesus42
JonasJesus42 merged commit c713343 into main Oct 7, 2026
1 check passed
@JonasJesus42
JonasJesus42 deleted the JonasJesus42/nuvemshop-image-cdn branch October 7, 2026 02:03
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.77.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

vitoUwu pushed a commit to vitoUwu/deco-start that referenced this pull request Nov 26, 2026
…ocms#493)

## Problem

The vite plugin's `meta.gen.json` auto-regeneration runs
`generate-schema.ts` **without `--compose`** at both invocation sites:

- `plugin.js` — watch-driven regen (fires on any `src/**/*.ts(x)`
add/change)
- `plugin.js` — cold-start bootstrap (when the file is absent)

`generate-schema.ts` defaults `COMPOSE = false`, and its own header
notes that without `--compose` the output "omits Page, matchers,
`__SECTION_REF__`, Resolvable that `composeMeta` otherwise [injects]".
So every regen writes an **uncomposed** manifest missing every framework
`website/*` block.

`meta.gen.json` is committed, and Studio reads it **as-is** (no
`composeMeta` at read time). In a sandbox session the plugin rewrites it
uncomposed, and the daemon's shutdown "sync all local changes" commits
it — clobbering the composed manifest on the branch. The admin editors
then break silently. Most visibly, `website/matchers/date.ts`
disappears, so the variant-rule editor ("Regra de variante") loses its
start/end **date fields**.

Reported on casaevideo-tanstack (["o campo com as datas sumiu de
novo"](deco-sites/casaevideo-tanstack#633)); a
`lebiscuit-tanstack` whose committed manifest was still composed was
unaffected. This recurred repeatedly (casaevideo decocms#494, decocms#566, decocms#633) —
each time a hotfix restored the composed file, but the plugin
re-clobbered it on the next session.

## Fix

Route both invocations through a new exported
`generateSchemaArgs(siteName)` helper that pins `--compose`, so the flag
can't drift off one site. This mirrors `npm run generate`'s schema step
(`blocks-cli generate --compose`) and the production build, which
already compose.

No other flags are needed: `generate-schema` defaults `--sections
src/sections`, `--loaders src/loaders`, `--apps src/apps`, out
`.deco/meta.gen.json` — exactly what sites pass. `composeMeta` is
dynamically imported from `@decocms/blocks`, which is installed in the
sandbox.

## Test

`generateSchemaArgs` unit test asserts `--compose` is always present and
the site is targeted. The invocations themselves live in the
`configureServer` closure (needs a live vite server to exercise), so the
helper is the unit boundary both sites derive their args from — the flag
can't silently drop off one again.

`npm run typecheck` and `vitest` (12 passed) green; no new Biome
diagnostics.

## Note

This is the generation-side root fix. The daemon committing a generated
`meta.gen.json` is by design (it's committed for cold-start, and a
vibecode agent may legitimately change an interface and regenerate it) —
the defect was purely that the sandbox regen produced a *degraded*
manifest.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Composes meta.gen.json during dev/sandbox schema regeneration to stop
committing an uncomposed manifest that removes framework website/*
blocks and breaks admin editors. Previously the Vite plugin ran
`generate-schema.ts` without `--compose`; now both watch and cold-start
invocations always include `--compose` via a shared helper.

- Centralizes args in `generateSchemaArgs(site)` and routes both
invocations through it, pinning `--compose`.
- Matches `npm run generate` and production behavior
(`@decocms/blocks-cli` with `--compose`).
- Adds unit tests that assert `--compose` is present and the target site
is set.
- No migration required; committed meta.gen.json remains composed and
features like the date matcher in the variant rule editor persist.

<sup>Written for commit b33d2bb.
Summary will update on new commits.</sup>

<a href="https://cubic.dev/pr/decocms/blocks/pull/493?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant