Hi there!
We have some Create React App users in https://github.com/facebook/create-react-app/issues/4680 using serve to host their production websites.
They are experiencing different behavior between our development server and serve which seems to be a bug, so I figured I'd post here.
Generally, we serve any file matching something on the filesystem. We fall back to index.html when nothing has matched (there's a few other rules on when to proxy, but they're not important for this example).
Serve appears to have the same behavior, but not in all cases. There appears to be a rule overriding the favoring of the filesystem.
Here's a demo of the behavior (humans.txt routes correctly but page2.html is transformed into page2):
Is this expected, or does it seem like a bug? Thanks!
same issue here, anything that is present on the filesystem is being redirected instead of serving it
Is this a regression btw? Or did it always work this way?
+1 same issue here. Makes it impossible to serve .html files.
Seems related to: https://github.com/zeit/serve-handler#cleanurls-booleanarray
I was able to access .html files after adding a serve.json file to my public folder with cleanUrls: false
I'm also following the Deployment guide for Create React App which lists serve as the first option (https://facebook.github.io/create-react-app/docs/deployment#static-server).
I've tried the cleanUrls config mentioned above by @laran in https://github.com/zeit/serve/issues/479#issuecomment-430312596 but that did not solve it for me.
When attempting to run the build with Serve, API proxying requests error out compared to running with react-app-rewired start. Unfortunately I don't have a simple MCVE to reproduce this outside of our app as I did not write the app code but I believe this would be the same case for any create-react-app using proxy (https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development). That said it's definitely possible that it can be done and I just haven't figured out the configuration.
Most helpful comment
Seems related to: https://github.com/zeit/serve-handler#cleanurls-booleanarray
I was able to access .html files after adding a serve.json file to my public folder with
cleanUrls: false