blob: 27609b8bdb20828346f978d6d354ca0cf36ad3bc [file] [log] [blame]
def main(request, response):
location = request.GET.first("location")
if request.method == "OPTIONS":
if "redirect_preflight" in request.GET:
response.status = 302
response.headers.set("Location", location)
else:
response.status = 200
response.headers.set("Access-Control-Allow-Methods", "GET")
response.headers.set("Access-Control-Max-Age", 1)
elif request.method == "GET":
response.status = 302
response.headers.set("Location", location)
if "allow_origin" in request.GET:
response.headers.set("Access-Control-Allow-Origin", request.headers.get("origin"))
if "allow_header" in request.GET:
response.headers.set("Access-Control-Allow-Headers", request.GET.first("allow_header"))