Vue.$http Cros Problem

  • Hello Guys,


    SAB , SPQRInc


    I want to send data to remote server with Vue js. But it's a cros error.




    I don't understand this error, I've tried too much but nothing ever worked. Do you have any idea?

  • You cannot do a crossbrowser with an xmlHttpRequest as it has a same domain policy. A workaround or trick for that is jsonp. vue-resource already has an implementation for this type of request, just use this.$http.jsonp().

    https://github.com/pagekit/vue…blob/develop/docs/http.md


    For explanation what jsonp does, take a look here:

    https://stackoverflow.com/ques…2/what-is-jsonp-all-about

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Can you give me examples of how it works. Because I'm not understand it

    Hello guys, my name is Yunus and I'm a backend developer. If you have a problem just drop me a message, but unfortinately I can't understand everything as I'm using google translator and many things gets lost in translation. So there is a language barrier and I'm sorry about this. Be patient and we will find a solution for sure. Thank you in advance.

    • Helpful
    Code
    1. clientAccessToken:function(){
    2. this.$http.jsonp('https://mobilwebsite.com.tr/apioauth2/client/authorize' , {
    3. secret_id:this.api.secret_id,
    4. secret_key:this.api.secret_key
    5. } , {credentials: true}).then( res => {
    6. console.log(res);
    7. } )
    8. }

    That should be the only thing to change

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Not worked :/

    Images

    Hello guys, my name is Yunus and I'm a backend developer. If you have a problem just drop me a message, but unfortinately I can't understand everything as I'm using google translator and many things gets lost in translation. So there is a language barrier and I'm sorry about this. Be patient and we will find a solution for sure. Thank you in advance.

  • It worked when I change file to htaccess but why It not worked when I set to the Response class


    Code
    1. <IfModule mod_headers.c>
    2. Header set Access-Control-Allow-Origin "*"
    3. Header set Access-Control-Allow-Credentials true
    4. Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    5. Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
    6. </IfModule>

    Hello guys, my name is Yunus and I'm a backend developer. If you have a problem just drop me a message, but unfortinately I can't understand everything as I'm using google translator and many things gets lost in translation. So there is a language barrier and I'm sorry about this. Be patient and we will find a solution for sure. Thank you in advance.

  • Yes, You saying correct. I could find safe methods at this weekend

    Hello guys, my name is Yunus and I'm a backend developer. If you have a problem just drop me a message, but unfortinately I can't understand everything as I'm using google translator and many things gets lost in translation. So there is a language barrier and I'm sorry about this. Be patient and we will find a solution for sure. Thank you in advance.

  • application/json is CORB protected. You have to return either text/javascript or application/javascript

    https://chromium.googlesource.…ead_blocking_explainer.md


    Does something like this work?

    Code
    1. $response = App::response()->json($data);
    2. $reponse->setCallback($callback); // $callback from @Request
    3. return $response;

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7