How to test api calls from flutter app to localhost service? - api

I'm trying to understand how to test http calls from my flutter app (which is running in an emulator) to my backend service, which is running in debug on my pc on https://localhost:8080.
I get that talking to https://localhost:8080 directly from flutter won't work because it means "emulator's localhost", so I'm talking to my pc local ip, but I got CERTIFICATE_VERIFY_FAILED because of course https://192.168.1.123:8080 doesn't have a signed cert.
What is the correct way to handle this situation?

You need to use the localhost of your host machine, not the localhost of your emulator. To do that you need to use 10.0.2.2 and then your port number, so in your case make http calls to https://10.0.2.2:8080. Internally Android reroutes calls to 10.0.2.2 to 127.0.0.1, which is the localhost ip on your dev machine.
How do you connect localhost in the Android emulator?
Some more info: https://developer.android.com/studio/run/emulator-networking.html

Related

why does json-server only work on localhost server?

I have an app where I used json-server to create a quick backend for me to test. My app now works the way I want it to, but I realized that my app doesn't work on other laptops/phones because my json-server uses localhost. Can json-server work with custom URLs, or does it only work on localhost? Do I have to start over and use a different backend? If so, does anyone have suggestions for which backend I should use?
If you want to test your backend on a cellphone or another thing you need two things
First
Your server and your client, in this case the cellphone both of them needs to be connected on the same wifi aka Local network
Second
Yow backend instead of pointing to localhost you need to specify the ip of your computer
json-server --host 192.168.0.xx file.json --port 4000

Can't connect to localhost after expo update

I use expo and my iphone for create react-native application locally. A few months ago all was good. I used my local ip address for connecting to my local backend server. But after update expo started generate url as exp://r2-asw...exp.direct:80. Now I always get a connection error. I even can use my api via browser using my ip and port.
If I choose LAN instead Tunnel there is an infinity loader and get an error "There was a problem running the requested app. The request timed out"
The problem was in mac Brandmauer

MITM Proxy - How to intercept user requests in reverse proxy mode from inside/outside Web Application Server

I am new to mitm.
https://mitmproxy.org/
AppServer1 (A windows 2016 server) has our IIS website application (WebApp1) running (its running fine without any problems currently).
I have added an SSL certificate as well, and it is loading fine without any issues.Chrome shows that it is trusted ("Connection is secure" when navigating from inside and outside AppServer1 server but "within the LAN". So far we havnt allowed access to internet users as of yet until the app is completely ready.)
We have a business requirement where
we need to intercept all traffic/requests from users from outide AppServer1
and send them to another application that we created (UserRequestDashboardApp),
and ALSO we need mitm to send it to WebApp1 as well.
I have read the articles multiple times and from what I understand, reverse proxy mode is the correct option to for our requirement.
WebApp1 is running on url - customappservice1.com, port - 443
I then started mitm (version 4.0.4) with the following CMD command
.\mitmdump -p 8080 --mode reverse:https://customappservice1.com
I get the status proxy server listening at http://*:8080
I dont seem to see any traffic in the terminal when I type customappservice1.com on AppServer1 chrome browser or any server browser outside AppServer1.
The WebApp1 pages load fine from outside and inside AppServer1 server but no traffic at all on the terminal
Can anyone please help me to capture the traffic on the terminal as an initial step before sending the traffic/requests to UserRequestDashboardApp AND WebApp1?
I have tried running mitm normally and it works fine(I can see traffic/requests fine in the terminal)
I launched mitm in CMD (It says Proxy Server listening at http://*:8080)
I set the
Windows server proxy to = localhost
Port = 8080
Did you try configuring your requests to use the mitmproxy's address ?
Also, web browsers may have use a separate proxy configuration from the operating system's. So you may try configuring Chrome's proxy settings.

Web RTC Server is running in localhost only

I've configured Web RTC sever in my PC. It's working with http://localhost:8080 But this server is not working with the IP address in another machines.
I've referred Web RTC Server with this URL.
It might be a certificate problem.
For Chrome you need to host your website on secure http (https) and your webrtc websocket needs to be also secured (wss). Localhost is an exception for this. You might try to test with Firefox as that doesn't require wss.
try start with mentioning --host=your local ip address

Cannot connect to meteor server running on virtualbox when using force-ssl

I have a windows 8.1 machine running ubuntu 14.x on a virtualbox. I'm running meteor inside that virtualbox. I've bridged the connection and turned off the firewall on both machines. I'm able to connect to the internet from the virtual box, and I can telnet from the windows host into the ubuntu machine.
I can also connect to meteor apps that are not using the force-ssl package; however, I CANNOT connect to meteor apps that are using force-ssl!
If I run "meteor remove force-ssl" I can connect to the app. Any thoughts? Thanks.
EDIT - by connect to the app, I mean "http://[ip_address_of_guest]:3000/" in a browser on the host machine. I've tried both http and https.
I'm new to Meteor but, from this documentation, it looks to me like you are seeing the intended behaviour ...
"This package, part of Webapp, causes Meteor to redirect insecure
connections (HTTP) to a secure URL (HTTPS). Use this package to ensure
that communication to the server is always encrypted to protect users
from active spoofing attacks.
To simplify development, unencrypted connections from localhost are
always accepted over HTTP.
Application bundles (meteor bundle) do not include an HTTPS server or
certificate. A proxy server that terminates SSL in front of a Meteor
bundle must set the standard x-forwarded-proto header for the
force-ssl package to work.
Applications deployed to meteor.com subdomains with meteor deploy are
automatically served via HTTPS using Meteor's certificate."
This answer clarifies.
I am about to try the Digital Ocean guide, "How To Deploy a Meteor.js Application on Ubuntu 14.04 with Nginx", myself to see if it correctly documents the required set up steps. I'll update with my results.