Layer7 API Management

 View Only
  • 1.  CORS issue while invoking custom endpoint

    Posted Oct 14, 2017 08:20 AM

    I am able to hit the other endpoints which are for resources/tables from the javascript code of my application from ajax but when I am trying to hit the custom endpoint I am getting the below error in the browser console.

     

    Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

     

    I got some solutions to send below in response header but It didn't work

    responseHeaders.put('Access-Control-Allow-Origin', '*');

     

    do we need to do something for the custom endpoint to make it accessible from the localhost?

     

    Please give your thoughts else I have to move my code to the functions from the custom endpoints.



  • 2.  Re: CORS issue while invoking custom endpoint

    Posted Nov 26, 2018 04:28 PM

    Please see our docs on how to create a HTTP Options Event Handler, available from Live API Creator 4.1 onwards. 

    From within the code editor of an Options Event (Request Events > Add > Options Event), there is code example available on how to modify the CORS response as well. 

     

    Hope this clarifies your question. 



  • 3.  Re: CORS issue while invoking custom endpoint

    Broadcom Employee
    Posted Dec 10, 2018 03:22 PM

    Good afternoon,

     

    Were you able to resolve the issue? What was the final result?

     

    Sincerely,


    Stephen Hughes
    Broadcom Support