Closed preetom1 closed 6 years ago
Hi @preetom1 😄
If it works locally with a proxy, but not when deployed to Heroku, then there's an inconsistency between your proxy configurations, or otherwise a difference between what's local vs deployed.
It looks like your local dev proxy declared in package.json
does not follow what is described in this buildpack's README Proxy for local development. Your local proxy sends all unhandled requests to the backend, but when deployed to Heroku only /api/
prefixed paths get proxied.
The intended proxy behavior is that all requests to /api/*
get proxied to the backend without the /api
prefix. That prefix prevents unintentional mistakes with overlaying frontend routes with backend routes. In other words, for the request to POST /api/analyze
the backend will receive POST /analyze
.
So, I think the solution is to:
package.json
proxy config to what's documented in Proxy for local developmentPOST /analyze
(instead of POST /api/analyze
)@mars thank you! You were correct in that there was a disconnect between my local and deployed configurations. I should have realized that the requests to /api/*
were getting proxied without the prefix. I followed your steps and the app seems to be working correctly now.
I'll follow up here if I encounter any other related problems, and thanks again! 😃
@mars thank you! You were correct in that there was a disconnect between my local and deployed configurations. I should have realized that the requests to
/api/*
were getting proxied without the prefix. I followed your steps and the app seems to be working correctly now.I'll follow up here if I encounter any other related problems, and thanks again! 😃
hey can you share your code please my app is still not working after all the corrections
Unfortunately I can't share the code since it's part of a private project I'm no longer working on 😕 Best of luck!
Hi,
I have a very similar problem to #111, but after reading through that one I still am unable to figure out why my setup isn't working. I have a Flask API set up at a different URL from my frontend React app, and the frontend app makes requests to the backend app through the Axios library. The requests look like this:
Here is my static.json:
Here is my package.json:
This is the output from
git push heroku master
:Seems to deploy fine. Finally, here are the logs from my backend app:
The strange thing to me is that my logs on the backend seem to be recording the requests when I try to use the client app, even though the request fails and the console prints
xhr.js:178 POST https://secure-temple-75313.herokuapp.com/api/analyze 404 (NOT FOUND)
. I would think if the request wasn't being sent to the API it wouldn't show up in the logs at all, but it looks like it does. But on the other hand, if it is sending the request, then I am not sure why the console is giving me a 404 for the client URL if it's being sent to the right place. Also, the logs are logging requests to/analyze
, when the calls to in the React code are to/api/analyze
.For reference, everything works fine when I run things locally and use the proxy in my webpack dev server.
I would appreciate any insight into what's happening/how to fix this issue, thanks in advance!