Axios request path error after vue packaging

this is the index.js configuration clipboard.png

storeclipboard.png
apihttp://localhost:8888

api
clipboard.png
where else do I need to configure?
and packaging. There are also errors in js and css paths

Mar.23,2021

generally speaking, the api interface will not be deployed in the same site as H5, so the packaged ajax request needs to be accompanied by the api domain name.
so when using axios, you should consider different environments using different configurations .

< H2 > configure < / H2 >

there are many ways to use different configurations. Post here the method I used (put it in src/config so that you don't have to restart the configuration during development)
clipboard.png

dev environment

export default {
  apiBaseUrl: '/apidomain',
};

prod environment

export default {
  apiBaseUrl: 'http://www.yimo.link',
};

proxy settings

proxyTable: {
  '/apidomain':{
    target:'http://test.api.com',//dev
    changeOrigin:true,
    pathRewrite: {
      '^/apidomain': ''
    }
  }
}
< H2 > use < / H2 >
import config from 'config'
import axios from 'axios'

axios.get(config.apiBaseUrl+"/...")

however, in formal projects, a filter is generally set to create a generic instance using
. For details, you can refer to a demo project

written earlier.

anios.get (url), url to write the absolute path, to ip or then http://localhost and port number are fully written.


the settings in your index.js are cross-domain proxies in the development environment, and the production environment is useless. In view of this production environment, the problem of requesting different domain names in the development environment, You can refer to my article the project built by vue-cli to deal with the problem of requesting different domain names in different environments ,


has the landlord solved the problem

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39496-2c197.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39496-2c197.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?