1 Reply Latest reply on Dec 16, 2017 1:04 AM by kduffy

    Angular 4 - PiWebApi CORS error

    Lukasz_Widziewicz

      Hi, I try use PiWebApi to consume data in Angular 4 (https://pisquare.osisoft.com/community/developers-club/blog/2017/10/30/announcing-pi-web-api-client-library-for-angular),

      but in FireFox i have error : "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://SERVER/piwebapi/dataservers?path=%5C%5CPISRV1. (Reason: CORS preflight channel did not succeed)."

      Could you help ?

       

      Regards,

      Łukasz Widziewicz

        • Re: Angular 4 - PiWebApi CORS error
          kduffy

          Hi Lukasz,

           

          Are you familiar with the concept of cross-origin resource sharing (CORS)? If not, I would recommend watching this video for a good explanation: CORS. Basically what happens is that the PI Web API is blocking the request because it's coming on your behalf from a website that's a different origin as the PI Web API. This could be a malicious request, so the PI Web API needs to be configured to allow certain headers, origins, and methods from outside of its own origin.

           

          The CORS related settings are handled within the AF Configuration database.

           

          The best way to get started in troubleshooting would be to use the browser's developer tools window to see the requests and responses and get more information about the specific CORS error that you're seeing. But I would recommend watching the above video and reading through the CORS settings documentation for an initial approach.

           

          Kelsey

          1 of 1 people found this helpful