Forum Discussion

F5_newbie's avatar
F5_newbie
Icon for Nimbostratus rankNimbostratus
May 07, 2020

Add CORS header to current Irule.

i need to add a CORS header to this Irule. Can someone tell me where it would go?

 

The CORS header i need added is Access-Control-Allow-Origin: *

 

Here is our current Irule.

 

when HTTP_REQUEST {

  set json "{ \"message\": {\"title\": \"System Maintenance\", \"body\": \"System is undergoing maintenance.\", \"summary\": \"Please try again later.\" }}"

HTTP::respond 418 content $json "Content-Type" "application/json"

TCP::close

}

  • At the end of the HTTP::respond it supports headers. Name then Value.

    HTTP::respond 418 content $json "Content-Type" "application/json" "Name" "Value" "Name" "Value" ....
  • Thank you. Sometimes seeing things written out in such a simple way immediately clears up the mistake. Mine was that I missed quotes on one of my values. Your example highlighted that to me immediately.