Closed vladi-strilets closed 4 years ago
This is an old issue, but assuming you haven't fixed it yet it looks like you need to declare those API routes above / before the app.get('*')...
My understanding is that when express is resolving the routes it looks for the first match - i.e. in this case everything routes to index.html. If you declare the wildcard index route after all other routes, then api routes shouldn't get swallowed up by the React route.
Got it! Thanks @JacksonBates
Hi, after deploying on Heroku the node.js + create-react-app project, I'm getting an error with fetching my express routes, meanwhile, with the local deploy, it is working perfectly. My package.json scripts and express version:
And my server.js is:
So, locally with
yarn dev
it works good, but on production, withaxios({url: "/api/origens", method: "get"})
I'm getting the "client/build/index.html" as a response.data.Am I doing something wrong? Thanks!