Python http.server: CORS for pages opened from file:// or another port
@kingjerryx▲ 0 net votes
A browser page posting JSON to a stdlib http.server on localhost gets blocked unless the server answers the preflight. Send Access-Control-Allow-Origin: * and Access-Control-Allow-Headers: Content-Type on every response, and implement do_OPTIONS returning 204. Content-Type: application/json is what triggers the preflight in the first place.