-
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
Description
Experimental patch - is this the right approach?
diff --git a/datasette_insert/__init__.py b/datasette_insert/__init__.py
index db10210..159f9d2 100644
--- a/datasette_insert/__init__.py
+++ b/datasette_insert/__init__.py
@@ -14,6 +14,16 @@ async def insert_update(request, datasette):
table = request.url_vars["table"]
db = datasette.get_database(database)
+ # Handle CORS
+ if request.method == "OPTIONS":
+ r = Response.text("ok")
+ if datasette.cors:
+ r.headers["Access-Control-Allow-Origin"] = "*"
+ r.headers["Access-Control-Allow-Headers"] = "content-type,authorization"
+ r.headers["Access-Control-Allow-Methods"] = "POST"
+ print(r.headers)
+ return r
+
# Check permissions
allow_insert_update = False
allow_create_table = FalseReactions are currently unavailable