I\'ve been looking on the web for a while and haven\'t found a solution to my problem which is similar to this StackOverflow question Docker HTTP-requests between containers. Bu
Since you make an Ajax call it will be sent by the browser which is client side and not server side. So when you make a call from
to app:3030
for API, your browser has no idea what app is. So you have few things you can do
/etc/hosts
app
Then when you browse app using app:3000
, app:3030
will automatically point to the correct address.
You can use javascript to get the url that you should be using for api
document.location.scheme + "://" + document.location.hostname + ":3030"
You can create nginx reverse proxy
location / {
proxy_pass http://localhost:3000;
location /api {
proxy_pass http://localhost:3030;
}
}
This will require some change in your code file so that you use /api