尝试部署 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/