I was using below KVM policy in the shared flow. When consumer was calling the proxy it was working fine.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <KeyValueMapOperations name="XYZ" mapIdentifier="XYZ"> <Scope>environment</Scope> <Get assignTo="private.ClientId"> <Key> <Parameter>ClientId</Parameter> </Key> </Get> <Scope>environment</Scope> </KeyValueMapOperations>
Then I changed the KVM policy to as below, the consumer started getting CORS error.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <KeyValueMapOperations mapIdentifier="ABC" async="false" continueOnError="false" enabled="true" name="GetKVM"> <DisplayName>GetKVM</DisplayName> <ExpiryTimeInSecs>864000</ExpiryTimeInSecs> <Scope>environment</Scope> <Get assignTo="ClientId" index="1"> <Key> <Parameter ref="request.header.x-api-key"/> </Key> </Get> </KeyValueMapOperations>
I already have CORS policy added in the target preflow as below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage name="add-cors" async="false" continueOnError="false" enabled="true"> <DisplayName>Add CORS</DisplayName> <FaultRules/> <Properties/> <Set> <Headers> <Header name="Access-Control-Allow-Origin">*</Header> <Header name="Access-Control-Allow-Headers">origin, x-requested-with, accept, content-type, authorization, x-api-key</Header> <Header name="Access-Control-Max-Age">3628800</Header> <Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE</Header> </Headers> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo type="response" createNew="false" transport="http"/> </AssignMessage>
I an using Verify access token and hence using below condition too.
<Step> <Name>FC-VerifyAccessToken</Name> <Condition>request.verb != "OPTIONS"</Condition> </Step>
There error started occurring only after the KVM policy change when I added
<Parameter ref="request.header.x-api-key"/>