Request to second app's url being overwritten

New guy to Fly here, if there is another topic or documentation that solves this issue, please point me in that direction.

I have 3 apps in an org, a database, a backend service in laravel, and a react frontend. I have the internal communcation between the database and the backend working fine using the database’s .internal address. I can also hit the backend’s endpoints in postman fine and it works.

But, when I try to make a request via axios to the backend app from the react app using the backend app’s .internal address, it’s not working, in fact it is hitting the route at the react app’s address. I have tried hardcoding the .internal address, and have set the address as a fly secret, but neither is working. I do not see anything in the logs on either machine.

Example to make it more clear: I have a login route, it should something like backend-app.internal/login yet, when I go to the frontend website and put in the login information, the POST is sent to react-app.fly/login which of course returns a 404.

It seems like the fly app is overwriting every URL and I feel like I’m missing something simple, but I can’t figure it out.

Here is the react .toml file.
image

Here is the react dockerfile:
image

Can anyone help?

Thanks

Further info:

I am using an axios helper file that I route all requests through so I can add my Bearer token. I confirmed if I bypass that file and just hit the endpoint directly without going through that client it works fine (side note: only works if I don’t hit the .internal address but the regular fly.dev address due to cors issues but I can live with that as it’s a little test project).

But if I use that client, it does not work. When debugging on the website, I see the correct URL is being passed in. It’s just eventually somewhere along the line that I can’t seem to find when debugging being changed to the frontend URL and I don’t know why.

Are you making the request from client-side JavaScript? If so, you’ll need to use the fly.dev or some public address, not internal. The request is coming from your machine, not from the machine serving the front-end.

Hello @pb30, I did change it to the fly.dev address. In the screenshot in my second comment above you can see that it is coming down at the fly.dev address, and here is the relevant part of the axios client file. So all of this is working in the sense that the URL is being set correctly, just for some reason it’s being overwritten somewhere but when going through a debugging session I’m not seeing where or how.

image

Do you have some example code of making a request you can share?

Does it work locally using fly.dev or is it overwritten there too?

Sure thing, example:
image

And I didn’t even think about testing it locally because it was working before I tried putting the app up on fly.io, but yea it’s doing the same thing locally (replacing it with localhost instead of my frontend.fly.dev address). My bad on that.

I wonder what changed. Later today I can try debugging it locally. The only things that have changed since it worked was the fly.toml page was added but I can’t imagine that being the cause. I can try debugging locally it a little bit later on today.

Figured it out, @pb30, axios needs to be set with baseURL not baseUrl which was causing the issue. Appreciate you getting me on the right track!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.