Vue-webpack Project Local Development environment Setup agent resolves cross-domain issues

Source: Internet
Author: User

Objective:

General cross-domain problems as long as the backend configuration, it is not necessary to do the front-end processing, but there is no guarantee that you encounter all the backend can handle this problem very well, this time may require the front-end setup agent to solve the problem.

Configuration method:

1. Config/index.js

  proxytable: {        '/api ': {            //  the domain name to access the interface            //  Secure: False,  //If it is an HTTPS interface, this parameter needs to be configured            true//  If the interface is cross-domain, this parameter configuration is required            pathrewrite: {              ' ^/api ': '// Override interface Access }}}     ,   ' 192.168.8.1 ',// native IP or localhost

Note:/api must have, the name can be different.

2. Interface access address changed to native access address + port + "/api"

default {  domin:"Http://192.168.8.1:8080/api"// Native access address + "/api" (also available with HTTP://LOCALHOST:8080/API) }

You can run it again.

Vue-webpack Project Local Development environment Setup agent resolves cross-domain issues

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.