Vue Axios cross-domain

Source: Internet
Author: User

Since vue2.0 officially chose Axios to complete the AJAX request, I recently started using Axios to write Ajax requests. The architecture I used before was both front and back, so there was a cross-domain problem. I wrote the Post request method based on Axios's official documentation on GitHub, but the error in the browser console console output cross-domain issues.

Server I've done the cross-domain processing in the header of the HTTP header message

Header

But the JS client I follow the official document operation, found that there are still cross-domain issues, and then I search the relevant solution on the Internet, I found the need in the JS client, that is, the HTTP request message header set encoding format Content-type to application/ x-www-form-urlencoded

Axios ({    method: ' Post ',    URL: ' Request address ',    data:{        param: ' parameter ' )    },      headers: {            ' content-type ': ' application/x-www-form-urlencoded ',       }}). Then (function(res) {    return res.data;});

If this is not the case, the post request is accessible to the server, but the server does not return to the client properly, and the output cross-domain error in the console console in the browser

Vue Axios cross-domain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.