Развертывание Vue CLI в службе приложений Azure в режиме истории

Привет, есть ли кто-нибудь, кто развернул приложение в службе приложений 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"
  }
}

И у меня есть файл 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

С уважением Даниэль


person Daniel Öhling    schedule 19.03.2019    source источник


Ответы (1)


я использую ИСС сервер

это мой код

  <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                     <rule name="Handle History Mode and custom 404/500" stopProcessing="true">
                       <match url="(.*)" />
                      <conditions logicalGrouping="MatchAll">
                         <add input="{​​​​​​​REQUEST_FILENAME}​​​​​​​" matchType="IsFile" negate="true" />
                         <add input="{​​​​​​​REQUEST_FILENAME}​​​​​​​" matchType="IsDirectory" negate="true" />
                      </conditions>
                      <action type="Rewrite" url="/" />
                    </rule>
    
    
                    <rule name="redirect all requests" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{​​​​​​​REQUEST_FILENAME}​​​​​​​" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                         </conditions>
                        <action type="Rewrite" url="index.html" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

я использую ту же документацию, но я не знаю, нужно ли мне что-то еще сделать, или я могу увидеть проблему где-то

person Quentin Merlin    schedule 16.02.2021