vendredi 17 juin 2016

Trying to perform Blob storage and adding the form data to data store Preflight Error

Using Google Appengine Endpoints Created A servlet to help handle form post data for registration and uploading of a logo image file. The way it works is that it first of all goes to a blob servlet which will then return a link like this

http://localhost:8080/_ah/upload/ag1oZXJjdWxlcy0yMDE1ciILEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18YgICAgICAqAkM

for my form post to redirect to the url generated by the blob servlet, The JUNIT test is working well, But when i try to accept from my frontend built with angular i get the first response from the blob servlet which our URL now processing our form post to that url returns this error

XMLHttpRequest cannot load http://localhost:8080/_ah/upload/ag1oZXJjdWxlcy0yMDE1ciILEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18YgICAgICAqAkM.<br> 
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' <br>    header is present on the requested resource.    <br>    Origin 'http://localhost:9000' is therefore not allowed access.

been battling with this for days , what seems to be the problem with preflight

See the front end (from localhost:9000) code

//send link to blob_store 
  /**
  blob_servlet_url is the link to our blob_servlet which is something like this localhost:8080/blob_servlet
  */
$http.get(blob_servlet_url)
  .success(function (data, status, headers, config) {
     //move our form data to server now
    uploadUrl=data; //return the url to forward form data
    console.log("Url:- "+data);
     var formData = {};

    $http({url:uploadUrl,method:'POST',data:formData}).then(
      function (resp) {
      //success
        console.log(resp);
    },
      function (reason) {
      //error 
      });


  })
  .error(function (data, status, header, config) {

  });

Aucun commentaire:

Enregistrer un commentaire