Are you facing CORS headers issue? If you want to understand it better, it has been defined well in https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS and https://en.wikipedia.org/wiki/Cross-origin_resource_sharing. You can also follow http://enable-cors.org/.
As you read, you would understand that you may have to pass the following response headers
Access-Control-Allow-Origin
Access-Control-Allow-Methods
Access-Control-Allow-Headers
It is straightforward to add the first two headers in the response path (i.e., Out Sequence). For third header i.e., Access-Control-Allow-Headers, you may have to use the value that has come in the request header "Access-Control-Request-Headers". If so, you can achieve this in two steps:
Step 1:
Get the value for header "Access-Control-Request-Headers" and store the value in synapse config scope. It means that the value will be available both in and out sequence.
Snippet that need to be added in "In Sequence":
<property name="Access-Control-Request-Headers" expression="get-property('transport', 'Access-Control-Request-Headers')"/>
Step 2:
Get the value from synapse config, and set it as response header
Snippet that need to be added in "Out Sequence":
<property name="Access-Control-Allow-Headers"
expression="$ctx:Access-Control-Request-Headers"
scope="transport"
type="STRING"/>
As you read, you would understand that you may have to pass the following response headers
Access-Control-Allow-Origin
Access-Control-Allow-Methods
Access-Control-Allow-Headers
It is straightforward to add the first two headers in the response path (i.e., Out Sequence). For third header i.e., Access-Control-Allow-Headers, you may have to use the value that has come in the request header "Access-Control-Request-Headers". If so, you can achieve this in two steps:
Step 1:
Get the value for header "Access-Control-Request-Headers" and store the value in synapse config scope. It means that the value will be available both in and out sequence.
Snippet that need to be added in "In Sequence":
<property name="Access-Control-Request-Headers" expression="get-property('transport', 'Access-Control-Request-Headers')"/>
Step 2:
Get the value from synapse config, and set it as response header
Snippet that need to be added in "Out Sequence":
<property name="Access-Control-Allow-Headers"
expression="$ctx:Access-Control-Request-Headers"
scope="transport"
type="STRING"/>
No comments:
Post a Comment