Closed Sydney-o9 closed 6 years ago
According to the last item in the create-react-app Offline First Considerations docs, fixing this config for this repo’s example /api
relative API path will require ejecting.
Perhaps the best solution is to document this limitation clearly, linking to the docs for disabling/unregistering the ServiceWorker.
I personally do not use the technique demonstrated by this repo. I always run APIs as separate web apps with CORS configured. Sorry this issue slipped under my radar. Thanks for bringing it up here!
I just ran through a fresh install from the newest create-react-app with ServiceWorker enabled (default setup) to test this issue. Here's what I observed:
/api
calls from within the React app work correctlyhttp://localhost:5000/api
directly responds with the whole React app, not just the JSON API response.While the second observation is not the expected behavior, I'm not convinced this is a real issue with this project. The whole purpose of this project is to demonstrate self-hosting an API in the same app. If you want to deploy an API for use by other apps/origins, then run it and the React UI as a separate Heroku apps instead of using this single-app architecture.
This is a great concept - thank you for taking the time to put this open source.
Quick note, I just tested it fetching the fresh
create-react-app
repo - it is using service workers .react-ui/src/index.js
I had to unregister the service worker to see
/api
correctly in both Chrome and Firefox. Safari was ok because it doesn't support Service Workers yet.Any ideas?