Forum Discussion
cv_01_137078
Nimbostratus
Nov 05, 2013Access-Control-Allow-Origin on F5
Please guide me as to how Access-Control-Allow-Origin header is inserted on F5
2 Replies
- Kevin_Stewart
Employee
Had to do a little research on CORS:
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
And based on the above, this is perhaps a start:
when HTTP_REQUEST { if { [HTTP::header exists Origin] } { set origin_host [HTTP::header Origin] } } when HTTP_RESPONSE { if { [info exists origin_host] } { if { $origin_host equals "http://www.example.com" } { HTTP::header insert Access-Control-Allow-Origin $origin_host } } }
- IheartF5_45022
Nacreous
Another way to approach is this (we actually have this running in prod - we have some clients for which CORS support in the server is mandatory, so we fake it);
when HTTP_REQUEST { if {[HTTP::method] eq "OPTIONS"} { HTTP::respond 200 Access-Control-Allow-Origin "[HTTP::header Origin]" \ Access-Control-Allow-Methods "POST, GET" \ Access-Control-Allow-Headers "soapaction" \ Access-Control-Allow-Credentials "true" return } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects