{"revision":"0ed62d2c742f8e20","language":"en","entry":{"id":"browser-apps","group":"guides","kind":"guide","title":"Call Veil from a website","summary":"Use fetch directly for public reads and message verification.","sections":[{"kind":"paragraph","text":"Public CORS endpoints accept requests from any origin without credentials. Use credentials set to omit if your fetch wrapper normally includes cookies. Your site’s Content Security Policy must allow connections to https://veil.rip."},{"kind":"code","language":"javascript","code":"const options = { credentials: \"omit\" };\nconst response = await fetch(\"https://veil.rip/o/veil.json\", options);\nif (!response.ok) throw new Error(`Veil replied ${response.status}`);\nconst card = await response.json();"},{"kind":"heading","text":"Send a signature block"},{"kind":"code","language":"javascript","code":"const headers = new Headers();\nheaders.set(\"Content-Type\", \"application/json\");\nconst response = await fetch(\"https://veil.rip/v1/verify\", {\n  method: \"POST\",\n  credentials: \"omit\",\n  headers,\n  body: JSON.stringify({ block })\n});\nconst verdict = await response.json();"},{"kind":"paragraph","text":"The browser handles the OPTIONS preflight. A supported preflight returns 204 and can be cached for 600 seconds. Allowed request headers are Accept, Content-Type, Cache-Control, If-None-Match and If-Modified-Since. JavaScript can read Date, ETag when present, and Retry-After."},{"kind":"heading","text":"Handle failures"},{"kind":"paragraph","text":"Read the HTTP status before using the body. Public validation errors and rate limits are readable JSON. A private endpoint or a request with credentials will fail the browser’s CORS check. Signed writes, pairing codes and account-linking states have separate access requirements."},{"kind":"paragraph","text":"A cached image or script may retain headers from before CORS was enabled. A versioned resource URL requests a fresh response. Public JSON APIs and message verification do not use that static-resource cache."}],"related":["verify-message","limits"],"errors":[],"documentationUrl":"https://veil.rip/docs/browser-apps"}}