Vue Project Axios Request interface, back-end proxy request interface 404, where does the problem occur?

Source: Internet
Author: User

In the Vue project, the list data needs to use the QQ music interface data, but the direct request does not have the host and the referer limit, needs to adopt the way of the back-end proxy. With Axios and Node Express, after implementation in Dev-server.js, restart the project, resulting in interface 404. The code is as follows:

  

After careful examination, the code is no problem, so in apirouts Console.log () print information, run no printing information, means that there is no running this part of the code. Then think of whether it is Webpack version update, configuration has been caused by the change. So after careful look at the configuration, found that webpack.dev.conf.js really different, the new version of the Devsever directly into the configuration.

Older versions of Webpack.dev.conf.js

  

New version of Webpack.dev.conf.js

  

Find the reason, I Baidu looking for a new version of how to configure, and then found the following this article, according to the above method, measured effectively, can obtain data.

Share to everyone: Vue Development request Local data configuration, old version dev-server.js, new version Webpack.dev.conf.js

Other places unchanged, just need to put the code in the Dev-server.js, add to the webpack.dev.conf.js can. The following is my configuration, measured effectively.

Solve a problem, or very rewarding.

Vue Project Axios Request interface, back-end proxy request interface 404, where does the problem occur?

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.