Skip to content
Foxipa
Code Completion 5 Challenges

Complete the code: Data Types & the CORS Trap

Fill in the missing payload types that keep the derived Content-Type on the safelist.

Beginner ~4 min read

Challenge 1

Send JSON without triggering Chrome's Blob throw or a preflight.

js Your answer
// safelisted, no-cors, no preflight:
navigator.sendBeacon(url, );
// server: JSON.parse(await req.text())

Press Ctrl⌘Enter to check your answer

Challenge 2

Send form-shaped telemetry through the safelist.

js Your answer
const body = new ({ event: 'pageview', id: 42 });
navigator.sendBeacon(url, body);

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Blob type that flips the beacon into cors mode.

js Your answer
// switches the request to cors mode + preflight:
new Blob([json], { type: '' })

Press Ctrl⌘Enter to check your answer

Challenge 4

The runtime type that flips the beacon into cors mode.

js Your answer
// derives a NON-safelisted Content-Type -> cors mode -> preflight
const payload = ;

Press Ctrl⌘Enter to check your answer

Challenge 5

Name the BodyInit member whose length cannot be charged — so keepalive rejects it.

js Your answer
// TypeError: length cannot be determined at queueing time
const stream = new ();
fetch(url, { method: 'POST', body: stream, keepalive: true });

Press Ctrl⌘Enter to check your answer