mars/create-react-app-buildpack

Proxy for deployment is not working

timothy-chan2 opened this issue · 1 comments

Good day,

Running my app locally on my computer, my app works fine. However, it shows a 404 error in the browser console on my deployed web page since it's using the client side URL (not the proxy's one but the original domain of the app):

GET https://***********.herokuapp.com/api/22724 404 (Not Found)

I've already looked at the old issues here but I haven't been able to solve my problem. I'd say the most similar one to mine is issue #111 but there's no solution. It seems that the axios GET request is just appending the original domain of the app URL instead of using the proxy back end URL I defined in static.json.

As far as I can tell the deployed app built successfully. All the files are already commited. static.json is exactly as shown in the README.md. I set API_URL as a Heroku Config Vars. I've already redeployed. I am working on the main branch. My axios request is as follows:

axios.get(`/api/${variable}`)

static.json

{
  "root": "build/",
  "routes": {
    "/**": "index.html"
  },
  "proxies": {
    "/api/": {
      "origin": "${API_URL}"
    }
  }
}

I figured it out. I had to add /api at the end of my API_URL value due to how I set up my back end.