Search code examples
azureazure-static-web-appazure-static-web-app-routing

Azure Static Web App ignoring config json sometimes


I'm deploying to a static web app in Azure, everything is mostly working well. However, I'm attempting to route paths with locales in them to specific index files with the appropriate language codes (this is a necessity for the project).

It seems to consistently honor the staticwebapp.config.json on the initial page load in an incognito browser only when doing a hard refresh.

Example: Hitting site.com/zh/app will use the index.zh.html file for the view

However, without the hard refresh, the index.html file is returned though this should seemingly never happen. This happens even after reloading the page after a hard refresh

staticwebapp.config.json

{
    "routes": [
        {
            "route": "/en*",
            "rewrite": "/index.en.html"
        },
        {
            "route": "/ja*",
            "rewrite": "/index.ja.html"
        },
        {
            "route": "/zh*",
            "rewrite": "/index.zh.html"
        }
    ],
    "responseOverrides": {
        "404": {
            "rewrite": "/index.en.html"
        }
    }
}

azure-pipeline-staticweb.yml (other steps redacted because of NDA stuff)

- task: AzureStaticWebApp@0
      inputs:
        app_build_command: 'yarn build:dev'
        output_location: './dist'
        config_file_location: './'
        skip_app_build: false
        is_static_export: true
        azure_static_web_apps_api_token: '$(Static-Web-App-Token)'

Solution

  • I believe I've figured this out, the issue does not lie with Azure Static Web Apps, per se, rather with the fact that the app I am hosting includes a service worker which is overriding the responses