A
A
Alexey Belov2019-02-20 13:41:07
Python
Alexey Belov, 2019-02-20 13:41:07

Why doesn't CORS work in Flask?

app = Flask(__name__)
cors = CORS(app, resources={r'*': {'origins': ['https://therighthairstyles.com']}})
r = Redis()


@app.after_request
def add_header(response):
  if response.status_code == 200:
    response.cache_control.max_age = EXPIRES
  else:
    response.cache_control.no_cache = True
  return response


@app.route('/')
def index():
  return render_template('index.html')


@app.route('/photo', methods=['GET', 'POST'])
def upload():
  if request.method == 'POST':
    if 'photo' not in request.files:
      return abort(400, description='There isn\'t photo field')

Such a code, but for some reason it does not work, I can access from a domain that is not in the list

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2019-02-20
@Alenorze

in sense I can get access from any domain?
cors only for js
, open an empty browser window, there is a console and do:
fetch("http://127.0.0.1:5000")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question