使用历史记录模式在Azure App Service上部署Vue CLI

问题描述 投票:0回答:1

嗨,是否有人已经将应用程序部署到azure应用程序服务并使历史模式工作?我一直在尝试,不能让它工作:S

我使用connect-history-api-fallback和我的package.json看起来像这样:

{
  "name": "wbo",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "start": "node server.js"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "buefy": "^0.7.3",
    "connect-history-api-fallback": "^1.6.0",
    "express": "^4.16.4",
    "js-cookie": "^2.2.0",
    "lodash": "^4.17.11",
    "nprogress": "^0.2.0",
    "vue": "^2.6.6",
    "vue-router": "^3.0.1",
    "vuelidate": "^0.7.4",
    "vuex": "^3.0.1",
    "vuex-persistedstate": "^2.5.4"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.5.0",
    "@vue/cli-plugin-eslint": "^3.5.0",
    "@vue/cli-service": "^3.5.0",
    "@vue/eslint-config-prettier": "^4.0.1",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "node-sass": "^4.9.0",
    "sass-loader": "^7.1.0",
    "vue-cli-plugin-buefy": "^0.3.5",
    "vue-template-compiler": "^2.5.21"
  }
}

我在root中有一个server.js文件,如下所示:

const express = require('express')
const history = require('connect-history-api-fallback')
const port = process.env.PORT || 8080
const app = express()

app.use(history())

app.use(express.static(__dirname + '/dist/'))
app.get('/*', function(req, res) {
  res.sendFile(__dirname + '/dist/html.html')
})
app.listen(port)

console.log('Server started....')

有谁知道我还需要做些什么,或者可以在某个地方看到问题:S

最好的问候Daniel

azure vue-router azure-web-app-service vue-cli-3 html5mode
1个回答
0
投票

好吧,因为你在服务器端使用节点。 vue-router官方文档已经提到了你需要添加它以便使用它的代码。

链接到official docs

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.