nuxt的代理的配置

老鼠愛打洞發表於2019-06-21

詳細請檢視 連結: https://www.cnblogs.com/laozhang-is-phi/p/10249248.html#autoid-7-0-0.
包括建立開始到結束的旅程

從Github上下載下來之後發現在代理出現錯誤

之後便是經過千辛萬苦到網上淘來了正確的代理本地代理方式

const webpack = require('webpack')


module.exports = {
  mode: 'universal',

  /*
  ** 頁面頭資訊
  */
  head: {
    title: 'tBug,一個專業的解決bug平臺',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { name: 'keywords', content: 'tbug部落格,.netcore,vue,ddd,sqlsugar,web開發,前後端分離,nuxt' },
      { hid: 'description', name: 'description', content: 'tbug部落格,.netcore,vue,ddd,sqlsugar,web開發,前後端分離,nuxt' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  /*
  ** 自定義載入條的樣式
  */
  loading: { color: '#44C1B8', height: '4px' },
  vender:[
    'element-ui', 'axios', '~untils/index.js'
  ],

  /*
  ** 全域性CSS
  */
  css: [
    'element-ui/lib/theme-chalk/index.css',
    { src: "mavon-editor/dist/css/index.css" },
    {src: '@/style/style.css', lang: 'css'}
  ],

  /*
  ** 在安裝app之前,載入外掛
  */
  plugins: [
    { src: '~plugins/element-ui', ssr: true },

    { src: '~plugins/nuxt-markdown.js',ssr: false  },
    { src: "~plugins/server_site/index", ssr: false }

  ],

  /*
  ** Nuxt.js modules
  */

  /*
  ** Axios module configuration
  */

  /*
  ** Build configuration
  */
  build: {
    build: {
      vendor: ['element-ui', 'axios', 'Button', 'Input', 'Tabs', 'Message', 'TabPane', 'Row', 'Col', 'Loading', 'Notification', 'Icon']
    },
    analyze: false,
    plugins: [
      new webpack.ContextReplacementPlugin(
        /highlight\.js\/lib\/languages$/,
        new RegExp(`^./(${['javascript', 'css', 'php', 'sql', 'python', 'bash'].join('|')})$`),
      )
    ],
    babel: {

    },
    /*
    ** Run ESLint on save
    */
    extend(config, ctx) {

    },
  },
  modules: [
    // Doc: https://github.com/nuxt-community/axios-module#usage
    '@nuxtjs/axios',

  ],
  axios: {
    proxy: true,
    prefix: '/api', // baseURL
    credentials: true,
  },
  proxy: {
    '/api/': {
      target: 'https://m.hzqcjt.com', // 代理地址
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      },
    },
  }
}

相關文章