【问题标题】:Azure React App 'You do not have permission to view this directory or page'Azure React App“您无权查看此目录或页面”
【发布时间】: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/'您无权查看此目录或页面'

【问题讨论】:

标签: reactjs azure azure-devops azure-web-app-service github-actions


【解决方案1】:

问题解决了。需要设置yaml变量为package:'build'

【讨论】:

  • 完美。也为我工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-02
  • 2021-01-29
  • 1970-01-01
  • 2021-01-25
  • 1970-01-01
相关资源
最近更新 更多