staticwebdev / react-basic

https://docs.microsoft.com/azure/static-web-apps/getting-started?tabs=react
18 stars 63 forks source link

Routing doesn't support both client-side routing and /public static files #3

Closed jeffersoneagley closed 2 years ago

jeffersoneagley commented 4 years ago

I have a React app using react-router-dom. I've been digging through the docs and as far as I can see, there's 2 route configs I can have are:

{
  "routes": [
    {
      "route": "/*",
      "serve": "/index.html",
      "statusCode": 200
    }
  ]
}

which does not allow me to serve any of my static content, or:

{
  "routes": [
    {
      "route": "/*",
      "serve": "/public",
      "statusCode": 200
    }
  ]
}

which doesn't support client-side routing.

If I do both, then it says that whichever is first overrides the second.

Is there a canonical pattern to support both requirements? Technically we don't actually support React if we can't do this.

aaronpowell commented 3 years ago

Sorry for missing this thread, for the record, a better place to ask questions about Static Web Apps is on their GitHub presence - https://github.com/azure/static-web-apps

Since the time you asked the question there's been an overhaul to configuration and routing. There are more advanced features around wildcards and navigation fallbacks which allows pattern matching on file extensions, which helps address the issue you're describing here.

Hopefully that addresses the problems you've mentioned here.