React-Native - can't fetch from connected Android device to localhost endpoint - json

Im pretty new to React Native and im trying to make an application.
I have a JSON post request that works on Postman and on Expo when i run it on web browser (with http://127.0.0.1:8080). But when i try to run it on an attached Android device my app doesn't actually fetch the data.
As far as i can tell there is some problem with the connection between my phone and my computer. But i can't seem to find it.
Extra info:
- both devices are connected to my internet
- calls to the firebase API work just fine
- changing the "http://localhost:8080/route" with my computers IPv4 address or 10.0.2.2:8080 doesnt work

First try this
- For android: run the following command in terminal and try again
adb reverse tcp:8081 tcp:8081
If it doesn't work try this
Shake device(android)
Select dev settings and click "Debug server host & port for device"
Under debugging type local ip address and port number. (Ex: http://127.0.0.1:8080)

Related

Chrome. Remote debugging from connected Android Device: CORS issue

I have a SPA running on my localhost:3000 and my ASP.NET Core 3.1 Web API running on localhost:44372.
I'm trying to debug the SPA from my connected Android Device. I connected the device, did port forwarding, everything is well, SPA gets opened, but then it does a request to Web API and receives CORS error. When I check network tab I see that the origin is https://localhost:3000, which is correct. Does chrome remote debugging mode somehow replace the origin, because everything works well if I open the SPA locally?
I tried to debug Web API project with custom middleware, but I'm unable to hit the breaking point: seems like it returns CORS error before pipeline even started.
Here are my CORS configs in Web API:
builder.UseCors(x => x
.WithOrigins("https://localhost:3000", "http://localhost:3000")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials())
UPDATE
The CORS errors:
UPDATE 2
I also forwarded the port 44372 which I have the Web API on and the error changed to: net::ERR_CERT_AUTHORITY_INVALID. Is this an issue with the chrome on android? I'm not quite sure how to address it. The issue seems to be with the Web API server certificate, because SPA gets loaded properly.
I managed to solve the issue by opening https://localhost:44372 on the Device. There I got a security warning, but when I chose "proceed to localhost (unsafe)" I was able to reach Web API. Then https://localhost:3000 started working well.

How can I force chrome to get the geolocation from GPS module connected to a USB port instead of getting it from router IP?

I'm working on a certain project that uses RasberryPi debian 7 google chrome to open get some work done, the thing is, the server (I made it with django) asks the rasberry pi about its location.
RasberryPi's google chrome gets the location from the wifi IP location service.
How can I change it to get the location from a GPS module I connected to RasberryPi USB port?
I configured the GPS module and it's ready the location well and everythin works fine, now I only need to force chrome to get its location from that GPS module.
I do not have RasberryPi but this way works in Android: Start a native GPS app alongside Chrome, and Chrome will use the GPS positions that have already been produced for the native app.

WebRTC, Camera in Chrome and https

I am developing an application that uses WebRTC and I want Chrome to use the system camera. From what I understand, the use of the camera is allowed (in the latest versions of Chrome) only from "secure locations" (https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins), like localhost and 127.0.0.1.
I want to test it locally and connect to the server both from a client that resides on the same pc as the server, and from a client from another pc. In particular, the client that connects from another pc needs to connect to the server using its IP address (I am developing/testing it in an Intranet), but the client cannot use the camera because it is not calling localhost.
Is there a way to disable this constraint, so that I am able to test it in an Intranet?
If not, are there any alternatives?
try the unsafely-treat-insecure-origin-as-secure flag in Chrome:
http://peter.sh/experiments/chromium-command-line-switches/#unsafely-treat-insecure-origin-as-secure

Remote Debugging won't connect

I sort of make shift followed this guide on how to setup remote debugging. Since I am using Adobe Animate to compile my app I assume it has done the majority of the build steps already as I get a similar screen described.
I don't understand though. Here I have port forwarding up on my router so that it goes to my PC. I have TCP port 7935 up and open. Windows firewall on or off doesn't seem to make difference. Windows firewall even prompted me to allow or deny fdb after I ran it. I can't get my phone to connect via remote debugging. I want to be able to send this to my client who is having issue with the app so I can see what's going on under the hood instead of relying on a giant sum of try/catch statements and screenshots. Any help?
I tried a dummy domain and it seems to know that it can't connect to it. When I try mine or my IPv4 it doesn't let me connect. It just freezes up the app.
I don't know whether it works or not in Animate CC, but it works via Flash Builder. I'm using Android real device and I have Android SDK tools installed on my PC
Yes, I have followed that tuts from official Adobe docs, but that doesn't work
First: Simply connect your device to your PC
Actually , you can debug your app remotely as long as your device has been connected with your PC. This step, doesn't necessarily requires FDB.
In my case , all I need was things like
adb connect 192.168.xx.xx:port
this will connect your Android device with your PC on your default network .
Second, set debug setting over network
You've done it in Animate CC, with addition you might want to check "install application on the connected device'
Third, just debug as usual
You can get all those debugging stuff including traces

Sending javascript code to a chrome app via the remote debug protocol

In the context of a unit test I need to send some code to the console of a chrome app I am developing. It's clear that I can do that from the chrome.debug API, but is there a way to do that from outside the browser?
Yes, there is a way; if you can do something with chrome.debug you can do so with remote debugging.
You need to enable remote debugging with command line switches; you can then connect to Chrome with a debugger client instance.
Google lists some existing debugger clients, and you can implement your own by following the debugger protocol (which works over HTTP+WebSockets).
The procedure for a debugger client is to request /json from the debugger port over HTTP, which lists all possible debug targets; the client then connects to the WebSocket associated with that target to work with it.