Conventional scheme

  1. The manifest. Set in json
"h5": {
		"devServer": {
			"port": 8000./ / the port number
			"disableHostCheck": true."proxy": {
				"/api": {
					"target": "Your service request address"."changeOrigin": true.// Whether to cross domains
					"secure": false // Set a proxy that supports HTTPS}}}}Copy the code
  1. Set in the vue. Config. Js
Module. Exports = {/ * URL: deployment of production environment and the development environment to distinguish the current environment, baseUrl has been deprecated since Vue CLI 3.3, to use publicPath * / publicPath: "", assetsDir: "static/lipin", outputDir: "dist", runtimeCompiler: true, productionSourceMap: False, /* webpack-dev-server configuration */ devServer: {/* automatically open browser */ open: true, /* set to 0.0.0.0 all addresses can access */ host: DevHost, port: devPort, HTTPS: false, hotOnly: false, /* Use proxy */ proxy: {'/': {/* Target proxy server address */ target: ChangeOrigin: proxy. ChangeOrigin,},},}Copy the code

For those who failed after the above operation, please see here

uni.request({
			    url: '/web/getUserInfo'.success: (res) = > {
			        console.log(res.data); }});Copy the code
uni.request({
			    url: 'https://www.baodu.com/web/getUserInfo'.success: (res) = > {
			        console.log(res.data); }});Copy the code

Summary: When encapsulating an interface, the URL should not write the requested address. This is a key point