gpt4 book ai didi

azure - Next JS 13 应用程序无法部署到 Azure 静态 Web 应用程序

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

我正在尝试将下一个 13 个应用程序目录应用程序部署到 Azure 静态 Web 应用程序,但当我访问该 URL 时,它返回 500 错误。我在 Azure 上看不到任何日志,在“诊断”选项卡下找不到它们。我的工作流程文件如下所示:

name: Azure Static Web Apps CI/CD

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ORANGE_DUNE_0B46C9510 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
app_build_command: "npm run build"
api_build_command: "rm -rf ./node_modules/@next/swc-* && rm -rf ./.next/cache"
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ORANGE_DUNE_0B46C9510 }}
action: "close"

npm run build 命令是下一个构建,npm run start 是下一个启动。我没有使用 next 导出,因为它不能与 i18 一起使用。我怎样才能成功部署到该网址?

最佳答案

  • 首先,我在我的环境中创建了一个 Next-js-app @13v。

enter image description here

  • 在 GitHub 上创建了一个新存储库来托管 Next.js 应用的源代码,并将应用推送到远程源。

enter image description here

  • 然后在门户中创建一个静态 Web 应用程序并将其与我的 GitHub 存储库链接。

enter image description here

这是我的 Yaml 代码,请查看下面。

name: Azure Static Web Apps CI/CD

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build And Deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "public"
api_location: ""
output_location: ""
app_build_command: "npm run start"
api_build_command: ""
skip_deploy_on_missing_secrets: true

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: "close"
app_location: "public"
api_location: ""
output_location: ""
app_build_command: "npm run start"
api_build_command: ""
  • 我能够构建和部署我的应用程序。

enter image description here

结果: enter image description here

关于azure - Next JS 13 应用程序无法部署到 Azure 静态 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76502045/

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