web123456

【Learn a little a day-04】Use agents to solve cross-domain problems (front-end)

  • import { defineConfig } from 'umi';
  • export default defineConfig({
  • base: '/demo/', //Route prefix, string
  • publicPath: '/demo/', //Configure webpack's PublicPath
  • devServer: { //Configure the development server
  • port: 9099, //Port number
  • },
  • nodeModulesTransform: { //Set the compilation method of dependent files in the node_modules directory
  • type: 'none', //None is compiled by default or all is compiled
  • },
  • proxy:{ //Configure the proxy, only effective when dev
  • 'api':{ //Identify the URL that needs to be converted to request
  • 'target': '', //Server domain name
  • 'changeOrigin': true, //Allow domain name conversion
  • 'pathRewrite':{ '^/api':''}, // Remove the API in the request url
  • },
  • '/user':{
  • target: `http://localhost:8080/`,
  • changeOrigin: true,
  • pathRewrite: {'':''},
  • }
  • },
  • layout:{},
  • exportStatic:{}, //Configure the output form of html, the default output value
  • dynamicImport:{}, //Whether on-demand loading is enabled, that is, whether to split the build product, download additional JS when needed and then execute it.
  • // favicon: '/demo/', //Configure favicon address
  • routes: [
  • { path: '/', component: '@/pages/index' },
  • ],
  • fastRefresh: {}, // Quick refresh, the component state can be maintained during development, and editing can provide instant feedback.
  • history:{ //Configure history types and configuration items for routing jumps and listening
  • type: 'browser', //browser、hash、memory
  • }
  • });