Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JET Error : Response to preflight request doesn't pass access control check: No 'Access-Control-Allo

Vinoth Kumar DevarajaJul 21 2017 — edited Jul 25 2017

Just followed the simple steps

1. scaffold an app using below comman

yo oraclejet:hybrid app --appname="testapp" --template=navbar --platform=android

  1. Added a button in about.html file
    

<form class="demo-signin-form oj-hybrid-padding-vertical" method="post" name="signInForm">

        \<div class="oj-hybrid-padding-top">

          \<button id="signInBtn" class="demo-signin-button oj-hybrid-padding-horizontal oj-button-jqui oj-button oj-component oj-enabled oj-button-full-chrome oj-button-text-only oj-component-initnode oj-default" data-bind="click: callRestAPI, ojComponent: {component:'ojButton', label: 'Sign In', chroming: 'full'}" aria-labelledby="ui-id-6">\<div class="oj-button-label">\<span class="oj-button-text" id="ui-id-6">Sign In\</span>\</div>\</button>

        \</div>

      \</form>

3.edited the about.js file with AJAX REST API call

callRestAPI=function(){

       $.ajax(

     {

      url: "[https://XXXXXXXXXXXXXX/services/rest/connect/v1.3/accounts](https://XXXXXXXXXXXXXX/services/rest/connect/v1.3/accounts)",

      type: 'GET',

      headers:{

           'Content-Type': 'application/json',

           'authorization': 'Basic XXXXXXXXXXXXXXXXX'

       },

        success: function(data)

        {

             var json = JSON.stringify($.parseJSON(data));

             var people = JSON.parse(json);

             alert(JSON.stringify(people));

             alert("success");

        },error:function(error)

        {

            alert("error");

        }

    })

}

when i run in brower its showing

XMLHttpRequest cannot load https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX/services/rest/connect/v1.3/accounts.

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:8383' is therefore not allowed access. The response had HTTP status code 401.

pastedImage_13.png

I am able to call the REST service from Advanced Rest Client and able to invoke it directly from browser. Let me know if I am missing something like proxy.

I have deployed it as Android APK but I am still getting the same error.

Thanks

Vinoth

This post has been answered by Vinoth Kumar Devaraja on Jul 24 2017
Jump to Answer
Comments
Post Details
Added on Jul 21 2017
10 comments
540 views