Skip to content

Commit

Permalink
fix: check before request
Browse files Browse the repository at this point in the history
  • Loading branch information
t-h2o committed Dec 7, 2024
1 parent 948ca7a commit 927fb91
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion backend/matcha/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask
from flask import Flask, request, jsonify
from flask_socketio import SocketIO
from flask_cors import CORS
from os import environ
Expand Down Expand Up @@ -42,4 +42,14 @@ def create_app():

socketio.on_namespace(MainNamespace("/"))

@app.before_request
def before_request():
headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
}
if request.method.lower() == "options":
return jsonify(headers), 200

return app

0 comments on commit 927fb91

Please sign in to comment.