Apache origin and header conversion to iRules

I need to take this an Irule f5 can you help me with this please

<IfModule mod_headers.c>
Header edit Set-Cookie ^(.*)$ $1;SameSite=None;Secure
SetEnvIf Origin “^http(s)?://(.+\.)?tgr\.cl$” AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials “true”
</IfModule>

Hi  @Patricio_quirog , I’m no expert on apache configs…but I think this duplicates the logic. Test for sure before rolling anything to a production environment:

when HTTP_REQUEST {
  set host [HTTP::host]
  if { $host ends_with “tgr.cl” } {
    set origin_match 1
  } else { ## what to do if it does not match? }
}
when HTTP_RESPONSE {
  if { [info exists origin_match] } {
    HTTP::header remove Access-Control-Allow-Origin
    HTTP::header remove Access-Control-Allow-Credentials
    HTTP::header insert Access-Control-Allow-Origin $host
    HTTP::header insert Access-Control-Allow-Credentials true
  }
}

thanks and  for sure put into a test enviroment first.