項目部署到Nginx上,因為/更目錄已經(jīng)給了其他權限,說下直接把項目放到了/dist下面,所以build時候assetsPublicPath改為了相對路徑build: { // Template for index.html index: path.resolve(__dirname, '../dist/index.html'), // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: './',build的時候接口也是直接請求根路徑是沒問題的const service = axios.create({ //baseURL: process.env.ENV_CONFIG=='dev'?'/api':'', // api的base_url baseURL: process.env.ENV_CONFIG=='dev'?'/api':process.env.BASE_API, timeout: 5000, // 請求超時時間 headers:{ 'isWeb': 1, 'Content-Type': "application/json;charset=utf-8"
}
})但是按照官方的說法,Nginx如這樣說的配置https://blog.csdn.net/u011025...,刷新還是報錯404,然后我搜了下說可能是assetsPublicPath配置成絕對路徑,但是配置成絕對路徑的話靜態(tài)資源就找不到了
vue history模式部署到Nginx刷新時404
慕姐4208626
2019-01-28 11:21:33