I developed a docker compose stack, with, let's say, an API and a frontend.
The frontend queries the API service with JavaScript Fetch calls. What I am trying to achieve is to fetch the API through the http://api/endpoint URL.
version: 3
services:
api:
build: ./api
ports:
- "5000:80"
frontend:
build: ./frontend
ports:
- "80:80"
Whenever I try to reach an API endpoint from the frontend:
from a terminal in the frontend container: curl http://api:5000/endpoint works
from my local browser: a fetch from my frontend to http://localhost:5000 works
from my local browser: a fetch from my frontend to http://api:5000 or http://api not found (of course, my local network is not the docker compose network)
Is there a possibility to map my container's traffic from my browser to the docker compose network? Or should I access my container from the browser differently?
I get that my javaScript is executed on runtime, therefore on my machine's network, but the "DNS" feature that docker compose offers is too good not to be used even on frontend development purposes.
Many thanks in advance guys for your ideas!
Related
I am new in reactjs and nodejs.I made an application with react frontend and express backend. There are axios post and get requests for get data from mssql database via express.
When the project in production level, I write the IPv4 address and port for access dashboard from another device in local network. After build,when I use for example localhost:5000 for requests, I can see all datas which are come from database in the device which react project running but with this I cant see datas from android phone in local network.
What should I do? Isn't there any other way than writing a static IP address? This project can be run different machines.
I am sorry for my spelling mistakes.
I have an Node App and an Angular App running on my System (LG Gram- Windows), and the node server is my API server and the angular App is consuming those APIs. The Angular server is served with --host 0.0.0.0 so that I can access the app through out my Local Network (WiFi). I tried to access the Angular app with my phone and other laptop (HP - Ubuntu), both the devices was able to access angular app, but the login call(Through the Angular APP) to node API from my phone is giving me an error, but the Ubuntu system is fine. I tried calling the Node API directly from both devices and was able to access it and got a response. The Ubuntu system had the same issue with login but it was somehow fixed. What could be the issue.
I have fixed the issue, Since both the Node and Angular server was running on the same machine, i have set the API url as http://localhost:4000/api which worked on the same laptop but not on my android device, which in fact is calling http://localhost:4000/api for the api calls, hence connection error (no server on port 4000 on my android device). When i changed the url to http://192.168.31.82:4000/api, my local network IP, it worked.
I have purchased a subscription to NameCheap VPS service.
I have nodejs api running locally that I want to expose.
Currently when visiting mydomain.com a static page is served. How do I expose my nodejs api and handle requests to for example mydomain.com/books?
I have run the steps descrived here
The following guide is useless.
I am very new in node.js, I am creating a bitcoin application in php and I need to use Bitgo API for creating wallet address and bitcoin transfer.
Bitgo have there API in node.js only. Please help me to call node.js API inside my php code.
Here is the API listed.
https://www.bitgo.com/api/?javascript#create-address
On user signup I need to execute the Bitgo API for creating addresses inside wallet. Bitgo returns the wallet address in response and I have to store in my database.
Thanks in advance!
The BitGo Express REST API is a lightweight service for developers that want to take advantage of BitGo but are developing in a language without a native BitGo SDK.
BitGo Express runs as a service in your own datacenter, and handles the client-side operations involving your own keys, such as partially signing transactions before submitting them to BitGo. This ensures your keys never leave your network, and are never seen by BitGo. BitGo Express can also proxy the standard BitGo REST APIs, providing a unified interface to BitGo through a single REST API.
To use BitGo Express:
Install BitGoJS
Run the following command in the bin directory:
./bitgo-express --debug --port 3080 --env test --bind localhost
Make all BitGo REST API calls to the machine on which bitgo-express is running.
Let's suppose a backend application, which exposes some Rest API, running on a Jetty webserver at address 192.168.1.10:8889.
I would like to have a frontend application (html/javascript only, on a apache2 webserver) running at the same IP but on a different port (e.g. 8000), which should consume the API exposed by the backend application.
How can i get this architecture working without get into "No 'Access-Control-Allow-Origin'" error?
I think that you should install a nginx proxy.
configure it as a reverse proxy you can see documentation here :
https://www.nginx.com/resources/admin-guide/reverse-proxy/
You can search on google for more specific documentation on what you want to do.