0

I have a flutter web app that runs fine locally, however, when uploaded to the Azure infrastructure (via Azure Static Web Apps) I run into problems using the PathUrlStrategy option - when the url is entered manually there's a 404 returned. From here it states that there's some server config to do (but isn't clear about what).

After a bit of digging, I've found a reference to a .htaccess file (problem seems to be similar - treating the path as a subdirectory) but I'm not sure how to apply it to the static web app config?

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

Thanks in advance,

1 Answer 1

1

Okay - got there in the end!

Using this, specifically this bit:

{
  "navigationFallback": {
    "rewrite": "/index.html"
  }
}

I've added a staticwebapp.config.json file to the root of the flutter app. This didn't seem to be utilised until also adding this line to pubspec.yaml

  assets:
    - staticwebapp.config.json
Sign up to request clarification or add additional context in comments.

1 Comment

this configuration is very helpful, thanks 🙏 in the github action i see this: ``` Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored. Copying 'staticwebapp.config.json' to build output ``` isn't necessary add the file into the pubspec.yaml, because the configuration is for Azure, not for flutter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.