Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cors fix news-flash #2632

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anyway/app_and_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_cors_config() -> dict:
r"/api/infographics-data": {"origins": "*"},
r"/api/infographics-data-by-location": {"origins": "*"},
r"/api/gps-to-location": {"origins": "*"},
r"/api/news-flash": {"origins": "*", "methods": ["GET", "PATCH", "OPTIONS"]},
r"/api/news-flash/*": {"origins": "*", "methods": ["GET", "PATCH", "OPTIONS"], "supports_credentials": True},
r"/api/news-flash-v2": {"origins": "*"},
r"/api/embedded-reports": {"origins": "*"},
r"/api/streets": {"origins": "*"},
Expand Down
10 changes: 1 addition & 9 deletions anyway/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,14 +1097,6 @@ def acc_in_area_query():

app.add_url_rule("/api/v1/news-flash", endpoint=None, view_func=news_flash, methods=["GET"])


@app.after_request
def add_allow_methods_header(response):
if request.path.startswith("/api/news-flash/"):
response.headers['Access-Control-Allow-Methods'] = "GET, POST, PATCH"
response.headers['Access-Control-Allow-Origin'] = "*"
return response

nf_parser = reqparse.RequestParser()
nf_parser.add_argument("id", type=int, help="News flash id")
nf_parser.add_argument("source", type=str, help="news flash source")
Expand Down Expand Up @@ -1176,7 +1168,7 @@ def datetime_to_str(val: datetime.datetime) -> str:
)


@api.route("/api/news-flash/<int:news_flash_id>", methods=["GET", "PATCH"])
@api.route("/api/news-flash/<int:news_flash_id>", methods=["GET", "PATCH", "OPTIONS"])
class ManageSingleNewsFlash(Resource):
@api.doc("get single news flash")
@api.response(404, "News flash not found")
Expand Down
Loading