I have written a flask app & deployed it to app engine that would run some python scripts and returns some data when I make a POST request to a url something like:
import logging
import firebase_admin
from firebase_admin import firestore
import flask
app = flask.Flask(__name__)
@app.route('/test', methods=['POST'])
def get_data():
data = flask.request.json
return flask.jsonify({"test":1000);
I'm trying to make a POST request like below to the " https://****.appspot.com/test" on the client which is a web app hosted on Firebase hosting but am getting 'Access-Control-Allow-Origin' error.
fetch('https://***.appspot.com/vrp', {
method: 'POST',
data: null
})
.then(response =>
console.log(`response is ` , response.json()))
I saw here that I can edit app.yaml but I can't figure it out. Am I making a mistake?
My app.yaml:
runtime: custom
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
python_version: 3
handlers:
- url: /*
static_dir: /
http_headers:
Access-Control-Allow-Origin: "*"
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
headers
configuration is only supported in the standard environmentapp.yaml
file, not in the flexible one. I think you may need to explicitly set the CORS headers in your app. – Dan Cornilescu