From 0f05db945ffd4bdb3073a9a7cb0321660194b634 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 10 Dec 2023 23:39:41 +0530 Subject: [PATCH] fix cors for pref --- cloud-functions/python/functions/performance/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cloud-functions/python/functions/performance/main.py b/cloud-functions/python/functions/performance/main.py index e528f14..e83663e 100644 --- a/cloud-functions/python/functions/performance/main.py +++ b/cloud-functions/python/functions/performance/main.py @@ -9,7 +9,7 @@ import sys import platform import os import io -from flask import send_file +from flask import make_response, send_file from datetime import datetime import re import xlsxwriter @@ -33,8 +33,8 @@ def performance(request): if request.method == 'OPTIONS': headers = { 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET', - 'Access-Control-Allow-Headers': 'Content-Type', + 'Access-Control-Allow-Methods': 'GET, POST', + # 'Access-Control-Allow-Headers': '*', # 'Access-Control-Max-Age': '3600' } @@ -320,4 +320,5 @@ def performance(request): file_data = io.BytesIO(f.read()) # application/vnd.ms-excel - return send_file(file_data, download_name= output_filename, mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") \ No newline at end of file + response = make_response(send_file(file_data, download_name= output_filename, mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), 200, headers) + return response \ No newline at end of file