i created a proxy there i added "CORS" assign message policy in the target endpoint and my virtualhost is secure and also i am passing https in swagger editor but still getting type error
although i tried with the generate Curl and import in postman it is working as expected
but i am not able to enable CORS to my proxy
here is my Proxy endpoint code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ProxyEndpoint name="default"> <PreFlow name="PreFlow"> <Request/> <Response/> </PreFlow> <Flows/> <PostFlow name="PostFlow"> <Request/> <Response/> </PostFlow> <HTTPProxyConnection> <BasePath>/topcalculator</BasePath> <VirtualHost>secure</VirtualHost> </HTTPProxyConnection> <RouteRule name="default"> <TargetEndpoint>TargetEndpoint-1</TargetEndpoint> </RouteRule> </ProxyEndpoint>
and here is my target endpoint code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <TargetEndpoint name="TargetEndpoint-1"> <Description/> <FaultRules/> <PreFlow name="PreFlow"> <Request/> <Response> <Step> <Name>add-cors</Name> </Step> </Response> </PreFlow> <PostFlow name="PostFlow"> <Request/> <Response/> </PostFlow> <Flows/> <HTTPTargetConnection> <URL>https://rohanjangid-eval-test.apigee.net/calculatorcheck</URL> </HTTPTargetConnection> </TargetEndpoint>
and here is assignmessage policy of CORS
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="add-cors"> <DisplayName>Add CORS</DisplayName> <FaultRules/> <Properties/> <Add> <Headers> <Header name="Access-Control-Allow-Origin">*</Header> <Header name="Access-Control-Allow-Headers">origin, x-requested-with, accept</Header> <Header name="Access-Control-Max-Age">3628800</Header> <Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE</Header> </Headers> </Add> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="response"/> </AssignMessage>
Any kind of suggestion or changes would be of great help.
Yes, specifically the section on handling CORS preflight requests ie OPTIONS
You should also use the trace tool to be able to debug how your proxy is responding to different requests
thanks for response i correctly added CORS policy you can see in the code and i dont see any mistake in trace session
it is showing method as options but i am passing as post method in swagger
in the trace section it is showing options method instead of POST method also in response it is not trace CORS policy that i added
As mentioned, you need to read the documentation on handling CORS preflight requests