Andrew Duffy
Andrew Duffy

Reputation: 563

Why staticwebapp.config.json is not being recognising for React Azure Static Web App

I have the following staticwebapp.config.json

{
  "navigationFallback": {
     "rewrite": "/index.html",
     "exclude": ["*.{css,scss,js,png,gif.ico,jpg,svg}"]
  }
}

I have placed it here as you can see

enter image description here

Do I have the staticwebapp.config.json in the correct folder?

But still it doesn't seem to get picked up? Eg /login route returns a 404

I assume I don't have to use the AzureStaticWebApp@0 task to build the react app to utilise the staticwebapp.config.json

Also when I navigate to "Configuration" in the azure portal and attempt to check "Enable configuration file changes" it checks but the save button remains disabled? So that option remains unchecked after refresh. Confused.

enter image description here

Upvotes: 1

Views: 452

Answers (1)

Pete - MSFT
Pete - MSFT

Reputation: 4309

You have an azure pipeline file. You have a public directory. If you are simply copying the public directory to the static site, your statiwebapp.config.json file will need to be in the root of the public directory.

If you are using the AzureStaticWebApp@0 task, then I think it's in the right folder.

I'm guessing because you haven't shown how you're deploying, or what's actually deployed to the static website. (I'm assuming the screenshot is from vscode of your source tree)

Upvotes: 0

Related Questions