1

In my flask application, I need to set Access-Control-Max-Age. What is the correct syntax for it?

from flask import Flask, send_from_directory
from flask_cors import CORS, cross_origin
app = Flask(__name__,static_folder='./build') 
CORS(app)

reference: https://flask-cors.readthedocs.io/en/latest/api.html

DragonKnight
  • 1,740
  • 2
  • 22
  • 35

1 Answers1

1

Take a look at flask_cors.CORS section, the max_age part.

max_age (timedelta, integer, string or None)

The maximum time for which this CORS request maybe cached. This value is set as the Access-Control-Max-Age header.

According to the docs, you may need to init your CORS with this parameter.

CORS(app, max_age=3600)
Darkborderman
  • 129
  • 3
  • 7
  • It is correct thanks. I am not sure why it was not working in my case. I have a long call with I tried to add `timeout: 10000000` on request header and also `max_age=10000000` but its failing to accept response. – DragonKnight Sep 24 '20 at 03:37