4 Replies Latest reply on Jul 11, 2018 8:55 PM by Jerome Lefebvre

    OMF & CORS

    idodds

      I’ve developed a few Python based examples and it works well, but I have been struggling to get a JavaScript example to work.

      (ref - https://github.com/osisoft/OMF-Samples/tree/master/Community%20Samples/JavaScript%20and%20HTML)

      It seems to be a CORS / pre-flight header type issue.

      Do you have any information / work arounds regarding how to configure the PI Connector Relay / PI Data Collection Manager services to allow CORS?

        • Re: OMF & CORS
          jyi

          Actually.... let me try this myself too! What is your error message?

          • Re: OMF & CORS
            John Messinger

            Hi Iain,

             

            I'm not sure I understand your issue here. There is no specific configuration that I have seen for handling CORS in the PI Connector Relay or PI Data Collection Manager. What is the specific error message you received?

             

            I am sending OMF data from devices on my home network to my PI Connector Relay instance running on an Azure VM. That VM has a CA issued certificate for my domain, and I have not had to configure any CORS related settings for the connector relay endpoint.

             

            Are you using a valid producer token when sending the OMF data to the connector relay? What error message(s) are appearing in the relay message log?

            • Re: OMF & CORS
              idodds

              I have implemented Python based application scripts that work fine with my producer key / PI Connector Relay,  so I know the system works.  The issue is with trying to run a JavaScript / HTML based application.

               

              The example file on GitHub even says....

              NOTE: Make sure that you have both configured CORS (this example requires a CORS-enabled endpoint) and that you have trusted the SSL certificate.

               

              The error I get in the browser is....

              Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 405.