Skip to content

Commit 6837c90

Browse files
committed
update cors server code
1 parent cf85059 commit 6837c90

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,20 @@ directory. This script will serve the tree locally.
216216
from http.server import HTTPServer, SimpleHTTPRequestHandler
217217
import sys
218218

219-
220219
class CORSRequestHandler(SimpleHTTPRequestHandler):
221-
220+
222221
def end_headers(self):
223222
self.send_header('Access-Control-Allow-Origin', '*')
224-
self.send_header('Access-Control-Allow-Methods', '*')
225-
self.send_header('Access-Control-Allow-Headers', '*')
223+
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
224+
self.send_header('Access-Control-Allow-Headers', 'Content-Type, Authorization')
226225
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
227226
return super(CORSRequestHandler, self).end_headers()
228227

229228
def do_OPTIONS(self):
230229
self.send_response(200)
230+
self.send_header('Access-Control-Allow-Origin', '*')
231+
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
232+
self.send_header('Access-Control-Allow-Headers', 'Content-Type, Authorization')
231233
self.end_headers()
232234

233235
host = sys.argv[1] if len(sys.argv) > 2 else '0.0.0.0'

0 commit comments

Comments
 (0)