Skip to content

Commit ce34e1d

Browse files
committed
ots: send /digest as text/plain to skip CORS preflight
application/vnd.opentimestamps.v1 is not a CORS-safelisted Content-Type, so the browser preflights every /digest POST with OPTIONS. The public OTS calendars (alice/bob/finney) 404 the OPTIONS request -- they implement only the protocol verbs, not OPTIONS -- so the actual POST never goes through. Verified live with curl: alice's POST response sets access-control-allow-origin: *, so a non-preflighted request gets through cleanly. Calendars don't validate Content-Type, they read the body bytes directly.
1 parent 2620e47 commit ce34e1d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

frontend/src/app/components/_ordpool/ots-stamp-verify/ots-stamp-verify.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,14 @@ export class OtsStampVerifyComponent {
204204
}
205205

206206
private async postDigestToCalendar(uri: string, digest: Uint8Array): Promise<Uint8Array> {
207+
// text/plain is a CORS-safelisted content type, so no preflight is sent.
208+
// The OTS calendars don't validate Content-Type, they only read the body.
209+
// If we send 'application/vnd.opentimestamps.v1' (the protocol-canonical
210+
// value) the browser preflights with OPTIONS, the calendars 404 the
211+
// OPTIONS, and the POST never happens. Verified live against alice.
207212
const resp = await fetch(uri + '/digest', {
208213
method: 'POST',
209-
headers: { 'Content-Type': 'application/vnd.opentimestamps.v1' },
214+
headers: { 'Content-Type': 'text/plain' },
210215
body: digest as BufferSource,
211216
});
212217
if (!resp.ok) throw new Error(uri + ' replied ' + resp.status);

0 commit comments

Comments
 (0)