in chalice/deploy/validate.py [0:0]
def _validate_cors_for_route(route_url, route_methods):
# type: (str, Dict[str, app.RouteEntry]) -> None
entries_with_cors = [
entry for entry in route_methods.values() if entry.cors
]
if entries_with_cors:
# If the user has enabled CORS, they can't also have an OPTIONS
# method because we'll create one for them. API gateway will
# raise an error about duplicate methods.
if 'OPTIONS' in route_methods:
raise ValueError(
"Route entry cannot have both cors=True and "
"methods=['OPTIONS', ...] configured. When "
"CORS is enabled, an OPTIONS method is automatically "
"added for you. Please remove 'OPTIONS' from the list of "
"configured HTTP methods for: %s" % route_url)
if not all(entries_with_cors[0].cors == entry.cors for entry in
entries_with_cors):
raise ValueError(
"Route may not have multiple differing CORS configurations. "
"Please ensure all views for \"%s\" that have CORS configured "
"have the same CORS configuration." % route_url
)