Browse API Reference

CORS and browser access

Load artwork from any origin, read render diagnostics from script, and keep the secret half of a key out of the browser.

Artwork loads in a page on any domain, and fetch() succeeds from any origin. Images are served with access-control-allow-origin: *. The data API sends the same header and accepts a CORS preflight.

Canvas access

Drawing GymAssets artwork into a <canvas> requires the crossorigin attribute. Without it the canvas is tainted, and toDataURL() and getImageData() throw:

HTML
<img
src="https://cdn.gymassets.dev/v1/pk_…/body/male/front.webp?primary=pectorals"
crossorigin="anonymous"
alt="Chest muscles highlighted"
/>

The image displays correctly either way. The failure appears only when script reads the pixels back, which is a confusing place to meet it.

Diagnostic headers

Script can read a response header only where it is named in access-control-expose-headers. The render routes name these:

HeaderReportsSent by
x-muscles-not-drawnRequested ids the sheet does not drawMusclegram render
x-muscles-unknownRequested ids that are not muscle idsMusclegram render
x-width-clampedThe width asked for and the width servedMusclegram render
x-art-statusThe state of the requested artworkEquipment render
x-quota-statusAllowance degradationBoth render routes

A Musclegram request reports a partial result on a 200. These headers are the only way to tell a render that highlighted nothing from one that highlighted everything.

Server-side requests

A browser is permitted to send the secret half of a key to the data API, which sends access-control-allow-headers: authorization.