Google Cloud Functions CORS Request (Python)

from flask import jsonifydef test_cors_json(request):    if request.method == 'OPTIONS':        headers = {            # 'Access-Control-Allow-Origin': 'https://mydomain.com',            'Access-Control-Allow-Origin': '*',            'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',            'Access-Control-Allow-Headers': 'Content-Type, Authorization',            'Access-Control-Max-Age': '3600'            # 'Access-Control-Allow-Credentials': 'true'        }        return ('', 204, headers)    '''    headers = {        'Access-Control-Allow-Origin': 'https://mydomain.com',        'Access-Control-Allow-Credentials': 'true'    }    return ('Hello World!', 200, headers)    '''    data = {        'name': 'Test CORS OK'    }    response = jsonify({        'data': data    })    response.headers.set('Access-Control-Allow-Origin', '*')    return response

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.