Create-react-app creating react projects, using Axios cross-domain

Source: Internet
Author: User

Recently use react to do project practiced hand, the project call interface has cross-domain problem, the reference plug-in is Axios,react project is created with Create-react-app, solve cross-domain problems can be set in the background Cros (cross-domain resource sharing), if the front-end solution can use the proxy, Projects built with Webpack can be configured in Webpack.config.js, Create-react-app-created projects Webpack configuration integration in React-script integration, not well configured, you can configure the proxy in the Package.json file .

  

Indicates that the prefix requested in the interface is the value of the proxy, such as the interface to be requested is https://www.aaa.com/app/userQry, in the Package.json proxy is set to ' Https://www.aaa.com/app ',

The URL for calling the function to request data is userqry. The following is the requested function.

Create-react-app creating react projects, using 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.