【发布时间】:2021-01-07 04:24:01
【问题描述】:
在尝试部署 React 应用时遇到 Azure 应用服务问题。我尝试了将 web.config 添加到我的 /src 文件夹的其他解决方案。
应用程序:使用 create-react-app 构建
Index.js:import "./web.config";
web.config:
<?xml version="1.0"?> <configuration> <system.webServer>
<rewrite>
<rules>
<rule name="React Routes" 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>
</rules>
</rewrite> </system.webServer> </configuration>
使用以下 github 操作 .yml 文件:
name: Build and deploy Node.js app to Azure Web App - fitrskills
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- uses: actions/checkout@master
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '12.13.0'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
with:
app-name: 'fitrskills'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_xyz123 }}
package: .`
错误:导航到https://fitrskills.azurewebsites.net/'您无权查看此目录或页面'
【问题讨论】:
-
几天前我遇到了完全相同的问题。检查我的这个仓库,它有一个适用于反应应用程序的 YAML - github.com/Jay-study-nildana/ReactJSRecipeApp
-
你也可以查看这个问题-stackoverflow.com/questions/63872925/…
标签: reactjs azure azure-devops azure-web-app-service github-actions