cors.py
1 from mitmproxy import http 2 from mitmproxy.http import HTTPFlow # For typing 3 4 5 def request(flow: HTTPFlow): 6 if flow.request.method == "OPTIONS": 7 # h = flow.request.headers 8 flow.response = http.Response.make( 9 200, 10 b"", 11 { 12 "content-type": "text/html", 13 "Access-Control-Allow-Origin": "*", # Add this header to allow all origins 14 "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE", # Add the allowed methods 15 "Access-Control-Allow-Headers": "Content-Type", # Add the allowed headers 16 }, 17 )