gpt4 book ai didi

azure - 使用历史记录模式在 Azure 应用服务上部署 Vue CLI

转载 作者:行者123 更新时间:2023-12-03 00:27:07 24 4
gpt4 key购买 nike

您好,有谁已将应用程序部署到 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

最诚挚的问候丹尼尔

最佳答案

我使用 ISS 服务器

这是我的代码

  <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>

我使用相同的文档,但我不知道是否还有更多我需要做的事情,或者可以在某处看到问题

关于azure - 使用历史记录模式在 Azure 应用服务上部署 Vue CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55246212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com