next.js JS 13应用无法部署到Azure静态Web应用

wdebmtf2  于 2023-06-22  发布在  其他
关注(0)|答案(1)|浏览(108)

我尝试将下一个13应用程序目录应用程序部署到Azure Static Web Apps,但当我转到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命令是next build,npm run start是next start。我没有使用下一个出口的原因,它不能与i18使用。为了成功地部署到URL,我可以做些什么?

gupuwyp2

gupuwyp21#

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

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

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

下面是我的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: ""
  • 我能够构建和部署我的应用程序。

**结果:**x1c4d 1x

相关问题