staticwebapp.config.json doesn't take effect

Paul Abbott 1 Reputation point
2022-07-06T18:20:15.857+00:00

I have devOps pipeline deploying to Azure Static Web App.
I also have a custom staticwebapp.config.json with some cache and CORS settings.
Previously everything was working, but now none of the settings in the config are taking effect.
The start of this trouble may have coincided with me changing the "app_location" to "www". Previously I was serving index.html from the root of the repository, but later I added a build script that outputs to /www.
I tried moving the config file staticwebapp.config.json to the /www folder, and moved it back to the root, but it doesn't seem to work in either location.

/staticwebapp.config.json

{  
  "routes": [  
    {  
      "route": "/channels/*",  
      "headers": {  
        "cache-control": "no-store, must-revalidate, no-cache, max-age=0"  
      }  
    }  
  ],  
  "globalHeaders": {  
    "Access-Control-Allow-Origin": "*",  
    "Access-Control-Allow-Methods": "GET, OPTIONS"  
  },  
  "mimeTypes": {  
    ".json": "text/json"  
  }  
}  

My pipeline settings exported from devops:

# Variable 'deployment_token' was defined in the Variables tab  
# Variable 'npm_config_cache' was defined in the Variables tab  
# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software  
trigger:  
  branches:  
    include:  
    - master  
jobs:  
- job: Job_1  
  displayName: Agent job 1  
  pool:  
    name: Azure Pipelines  
  steps:  
  - checkout: self  
    fetchDepth: 1  
  - task: Cache@2  
    displayName: npm Cache  
    inputs:  
      key: npm | "$(Agent.OS)" | package-lock.json  
      path: $(npm_config_cache)  
      restoreKeys: npm | "$(Agent.OS)"  
  - task: Npm@1  
    displayName: npm install  
    inputs:  
      verbose: false  
  - task: gulp@0  
    displayName: 'Run gulp '  
    inputs:  
      arguments: --release  
  - task: AzureStaticWebApp@0  
    displayName: 'Static Web App: '  
    inputs:  
      app_location: www  
      skip_app_build: true  
      skip_api_build: false  
      is_static_export: false  
      verbose: true  
      azure_static_web_apps_api_token: $(deployment_token)  
...  
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
851 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Paul Abbott 1 Reputation point
    2022-07-07T00:43:21.293+00:00

    Oops! Finally figured out that my build script first step is a clean which deleted all the *.json files in the /www dir. (including the staticwebapp.config.json)