Troubleshooting Guide
Diagnose missing assets, invalid parameters, JSON API responses, CORS failures and framework configuration without requiring a package manager.
The image returns 404
A 404 means the requested path does not match a published file. Check asset type, quality, Unicode ID and filename casing:
- Emoji SVG:
/emojis/svg/1f632.svg - Emoji PNG:
/emojis/72x72/1f632.png - Flag SVG:
/flag/l/IN.svg - Flag icon:
/flags/4x3/in.svg
The JSON resolver constructs a URL but does not check whether the underlying file exists.
The JSON API returns HTTP 400
Confirm that type and id are present, and that quality matches the selected type.
const response = await fetch(apiUrl);
const result = await response.json();
if (!response.ok || !result.ok) {
console.error(result.error.code, result.error.message);
}Emoji quality must be svg or png; flag quality must be s, m or l; flag-icon quality must be 1x1 or 4x3.
The API route returns 404 after deployment
Check that the deployed project includes functions/api/v1/asset.js and that _routes.json contains /api/v1/*. Pages Functions use file-based routing; this file maps to /api/v1/asset.
If the project was deployed through a direct static upload rather than a Git-connected or Wrangler Pages deployment, verify that the deployment method supports Pages Functions.
CORS or fetch errors
The JSON resolver sends its own wildcard CORS headers for its public, read-only response. Static image files use the exact configured site-origin allowlist. An ordinary img element can display a cross-origin image without granting JavaScript permission to read its response.
For details, see CORS & crawlers.
The browser helper is undefined
The optional helper is a standalone browser script. Confirm that it loads before your application code:
<script defer src="https://softhoursdiary-emojis.pages.dev/[soft-hours-diary.js"></script>
<script defer src="/assets/app.js"></script>Deferred scripts execute in document order. The direct URL and JSON API methods do not depend on this script.
No package installation is available
That is intentional. Use a direct image URL, call the JSON resolver at /api/v1/asset, or load the optional browser script with a script tag. No npm installation is required.