Skip to content

fix: download the selected rows' images through the API - #398

Merged
nGervasyuk merged 2 commits into
Visual-Regression-Tracker:masterfrom
nGervasyuk:fix/download-images-cors
Aug 23, 2026
Merged

fix: download the selected rows' images through the API#398
nGervasyuk merged 2 commits into
Visual-Regression-Tracker:masterfrom
nGervasyuk:fix/download-images-cors

Conversation

@nGervasyuk

@nGervasyuk nGervasyuk commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Problem

"Download images for selected rows" does nothing on S3-backed deployments. The zip is built in the browser, so each image is fetched, and staticService.getImage points at GET /images/:fileName — which redirects to a pre-signed S3 URL with no CORS headers, so every fetch is blocked:

Access to fetch at 'https://<bucket>.s3.<region>.amazonaws.com/…' (redirected from
'https://<vrt>/images/…screenshot.png') has been blocked by CORS policy
GET https://<bucket>.s3.<region>.amazonaws.com/… net::ERR_FAILED 200 (OK)   static.service.ts:19

The same images display fine, because an <img> tag is not subject to CORS — so the failure is only visible in the console.

Change

  • fetch the bytes from the API's own origin via /images/:fileName/download (fix: serve image bytes from the API for bulk download backend#369) instead of the redirecting display URL. Display keeps using getImage, so image traffic still bypasses the API.
  • fall back to the redirect when the API answers 404 for that route, so this works against an API with or without the new endpoint — no deploy ordering between the two repos.
  • throw with the status code when a response is not ok, so a missing image can no longer end up inside the zip as an error body named <screen>.png.

Type-checked; unit and integration suites pass (the integration environment runs a published API without the new route, which is exactly the fallback path).


Nothing to configure. Independent of the other open frontend PRs (#397, #398, #399, #400, #401) — verified that they all merge onto master in sequence without conflicts, in any order.

@pashidlos pashidlos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nGervasyuk
nGervasyuk force-pushed the fix/download-images-cors branch from 2cf627b to 7e59d51 Compare August 23, 2026 06:30
The zip is built in the browser, so each image is fetched. getImage points
at GET /images/:fileName, which redirects to storage — with S3 that is a
pre-signed URL without CORS headers, so the fetch is blocked and the whole
download fails while the same images still display fine in <img> tags.

Fetch the bytes from the API's own /download route instead, falling back to
the redirect when the API does not have that route yet, so this works against
either API version. A response that is not ok now throws with its status
code, so a missing image cannot end up in the zip as an error body named
like a screenshot.
The integration suite stubs the API, so the new /images/:fileName/download
request had no handler and failed as a network error rather than exercising
the download.
@nGervasyuk
nGervasyuk force-pushed the fix/download-images-cors branch from 7e59d51 to 90f9f40 Compare August 23, 2026 06:36
@sonarqubecloud

Copy link
Copy Markdown

@nGervasyuk
nGervasyuk merged commit b22aaa4 into Visual-Regression-Tracker:master Aug 23, 2026
3 checks passed
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.

2 participants