Azure / Azure/static-web-apps

Getting a 502 Server Error on Static Web App

Open
#784 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I'm deploying a Next.js React app using Azure pipelines. The deployment is working just fine, but I can no longer access the site once it's done.

This has been working just fine for weeks up until yesterday. I'm now getting a 502 on page load.

Here is my pipeline YML. This is deploying just fine in Azure Devops:

```yml
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

# Trigger builds on commits to branches
trigger:
- main
- dev

# Do not trigger builds on PRs
pr: none

variables:
${{ if eq(variables['Build.SourceBranchName'], 'main') }}:
api_url: $(NEXT_PUBLIC_API_URL_PROD)
app_env: 'production'
static_web_app_deploy_token: $(DEPLOYMENT_TOKEN_PROD)
${{ if eq(variables['Build.SourceBranchName'], 'dev') }}:
api_url: $(NEXT_PUBLIC_API_URL_PROD)
app_env: 'development'
static_web_app_deploy_token: $(DEPLOYMENT_TOKEN_DEV)

stages:
- stage: test
displayName: 'Lint and Test'
jobs:
- job: lint_test
displayName: 'Lint and Test'
pool:
vmImage: ubuntu-latest

steps:
- task: CmdLine@2
inputs:
script: |
yarn
yarn run lint
yarn run test

- stage: 'Deploy'
displayName: 'Deploy'
jobs:
- deployment: Deploy

environment: ${{ variables.app_env }}

strategy:
runOnce:
deploy:
steps:
- script: git config --global init.defaultBranch main
displayName: 'Setting git config default branch'

- checkout: self
submodules: true

- script: echo 'Deploying to ${{ variables.app_env }}'
displayName: 'Print deployment environment'

- task: AzureStaticWebApp@0
inputs:
app_location: '/'
output_location: '/packages/main-app/out'
azure_static_web_apps_api_token: ${{ variables.static_web_app_deploy_token }}
env:
NEXT_PUBLIC_ADMIN_API_URL: ${{ variables.api_url }}
NEXT_PUBLIC_APP_ENV: ${{ variables.app_env }}
NEXT_PUBLIC_AZURE_AD_CLIENT_ID: $(NEXT_PUBLIC_AZURE_AD_CLIENT_ID)
NEXT_PUBLIC_AZURE_AD_TENANT_ID: $(NEXT_PUBLIC_AZURE_AD_TENANT_ID)

```

**Expected behavior**
Should be able to access the static web app URL without any errors.

**Device info (if applicable):**
N/A

**Additional context**
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.