openpencil/apps
Fini c6d47dd689 fix(canvas): asset resolver passes through same-origin /api routes
Image #42 logs showed every image fetch URL came out wrapped twice:
  http://localhost:3000/api/local-asset?path=%2Fapi%2Fai%2Fimage-proxy%3Furl%3D...

The image-search pipeline correctly returned
\`/api/ai/image-proxy?url=...\` thumbUrls (so browser fetches go
through the dev server, which can reach openverse via the system
proxy). But \`isLocalAssetPath\` only excluded \`data:\`/\`https?:\`/
\`blob:\` from local-asset bridging — anything else, including
absolute paths starting with \`/api/\`, was treated as a file-system
asset and re-wrapped through \`/api/local-asset?path=\`. That bridge
handler then 404s because the encoded path \`/api/ai/image-proxy?...\`
isn't a real file. Net effect: every search-found image stayed at
the placeholder visual even though the search succeeded.

Add a same-origin route carve-out:
  /^\/(?:api|_)\//

Paths under those prefixes are runtime endpoints (Nitro \`/api/*\`,
Vite \`/_/*\`), not file system assets, so they pass through the
resolver as-is. \`/assets/hero.png\` and similar absolute file-style
paths still go through the local-asset bridge.

New regression test covers /api/ai/image-proxy, /api/local-asset,
and /_/* paths returning false from isLocalAssetPath, and verifies
ordinary /assets/... paths still return true.
2026-05-05 12:22:56 +08:00
..
cli Merge origin/v0.8.0 into feat/rust-ification 2026-05-03 21:00:00 +08:00
desktop Merge origin/v0.8.0 into feat/rust-ification 2026-05-03 21:00:00 +08:00
web fix(canvas): asset resolver passes through same-origin /api routes 2026-05-05 12:22:56 +08:00