DataPower

 View Only
  • 1.  I want to remove the CORS Headers - Access-Control-Allow-Origin & Access-Control-Allow-Methods from Response sent to client

    Posted 16 days ago

    I want to remove the CORS Headers - Access-Control-Allow-Origin & Access-Control-Allow-Methods from the response for a service.

    I tried the following methods in the assembly but they didnt work. 

    Javascript :

    hm.current.remove('Access-Control-Allow-Origin');

    XSLT:

    <dp:remove-http-response-header name="Access-Control-Allow-Origin"/>



    ------------------------------
    Kshitij Khanna
    ------------------------------


  • 2.  RE: I want to remove the CORS Headers - Access-Control-Allow-Origin & Access-Control-Allow-Methods from Response sent to client

    IBM Champion
    Posted 16 days ago

    Have you tried in GWS:

          

    
    

    var apim = require('./apim.custom.js');

    ....

    apim.setvariable('message.headers.Access-Control-Allow-Origin', 'null', 'clear');



    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: I want to remove the CORS Headers - Access-Control-Allow-Origin & Access-Control-Allow-Methods from Response sent to client

    Posted 13 days ago

    Hi 2 things: can I ask why you would need to remove those headers?

    Also, i am not sure if that is possible in the apigw but if necessary you could remove them using a proxy mpgw sitting between the apigw & the client.



    ------------------------------
    Matthias Siebler
    MA
    ------------------------------



  • 4.  RE: I want to remove the CORS Headers - Access-Control-Allow-Origin & Access-Control-Allow-Methods from Response sent to client

    IBM Champion
    Posted 11 days ago

    Hi,

    I have always thought that the easiest way to strip headers is to use Header suppression config under Headers tab. This goes for Multiprotocol Gateway, XML Firewall and Web Service Gateway. If you are using API Gateway, then Joseph and Matthias had some ideas on how to solve the issue.



    ------------------------------
    Hermanni Pernaa
    ------------------------------