AWS API Gateway - CORS “access-control-allow-origin” - multiple entries

后端 未结 4 1023
南方客
南方客 2020-12-31 09:13

I have a AWS Lambda instance that connects to a defined AWS API Gateway. If I enable CORS and give the access-control-allow-origin a definition of http:/

4条回答
  •  醉酒成梦
    2020-12-31 10:05

    Why not use Velocity Template language mapping template to check from a list of allowed domains and set the origin header

    $input.json("$")
    #set($domains = ["https://www.example.com", "https://www.abcd.com"])
    #set($origin = $input.params("origin"))
    #if($domains.contains($origin))
    #set($context.responseOverride.header.Access-Control-Allow-Origin="$origin")
    #end
    

提交回复
热议问题