reactjs - Azure React应用程序 'You do not have permission to view this directory or page'

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

尝试部署 React 应用程序时遇到 Azure 应用服务问题。我尝试过将 web.config 添加到我的/src 文件夹的其他解决方案。

应用程序:使用 create-react-app 构建

Index.js:导入“./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 actions .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变量来打包:'build'

关于reactjs - Azure React应用程序 'You do not have permission to view this directory or page',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63986085/

相关文章:

javascript - 如何根据 Electron 菜单点击更改 Redux 状态?

javascript - 获取 "Object is possibly ' null'。 TS2531”在表单输入字段上

android - 创建一个 DateTimePicker React-Native Android?

azure - ARM 资源迭代因空数组而失败

azure - Azure辅助角色 e :\approot folder disappearing on instance reboot 的内容

c# - 使用 Azure Functions 和 .NET 5 将不同的连接字符串传递到 IDesignTimeDbContextFactory(独立)

azure-devops - 自动删除 TFS 项目模板自定义

reactjs - 如何测试渲染的 React 组件的 HTML?

powershell - 如何在经典devop(不是yaml)中设置变量并在不同任务之间传递?

javascript - Azure DevOps 在部署之前更新代码内的变量