Create-react-app netlify.toml redirects rule redirects all static js files to index.html

netlify dev with the following redirects rule on create-react-app (latest version 3.4.1) causes all requests to the /static dir to be redirected to /index.html.

[[redirects]]
from = "/*"
to = "/index.html"
status = 200

This causes e.g. the /static/bundle.js to return the index.html causing a syntax error as shown in screen shot of dev tools:

Screenshot 2020-04-01 at 20.00.49

The only way I’ve been able to solve it so far is to add a redirect rule for /static/* to /static/:splat above the existing rule i.e.

[[redirects]]
from = "/static/*"
to = "/static/:splat"
status = 200

This seems wrong, weirdly there is no issue on live .netlify.com url. Only netlify dev. Am running version 2.40.0 of netlify-cli.

This is really weird but I just commented out my /static redirect and it’s working now. No idea why as haven’t changed anything else and restarted netlify dev multiple times when before raising the issue.

Anyway it’s resolved for me now so disregard

1 Like

great, thanks for letting us know.

I also have this issue and have been unable to fix it without the hacky redirect rule. Also have to shift-reload every load (to clear cache?) if using netlify dev. Without doing so my app just renders empty html.

Hi, @bradleygriffith and @bristoljon. I am able to reproduce this as well and I’ve filed an issue for this here:

This topic and issue are cross-linked. It is a public repo so please feel free to watch the issue there. We’ll also post an update here if/when the issue is known to be resolved.

Think we got that fixed a few days ago, Bradley - could you confirm/deny if is working better with the latest 2.49 or greater CLI version?