Impossible to use proxy - react-native

I'm trying to use proxy with my react-native app (build with CRNA and Expo).
So in my package.json file I put : "proxy": "192.168.1.27:8080" and then make simple get request with fetch with the/users` path and react call me network error (he don't see the proxy param, just /users when I'm debugging).
The fetch request work well if I put the full url.
In react (for website) I do the same thing and that's work to.
Thank's for your help.

In Reactjs proxies are mainly used to avoid cors issues. Since React Native connects to iOS & Android natively, there is no browser issue so you don't need a proxy.
The approach I use is to call http:127.0.0.1:nnnn/api/route (not localhost) in the React Native app when testing the backend, and the deployed url in production. So you can deploy your server separately and reach it directly in the app.

Related

React Native how can ะจ create http websocket for handle post request

I have a react native project that was created on the expo and will work on android.
I want to create a HTTP server on any port on localhost and I will take the request body from there and use it anywhere on my project.
How can I do that?
Apk will work on a phone that will be connected to a different network. I can't connect to the internet

How do I create a http redirect url for react native expo app?

I have a third-party OAuth in my react-native expo app.
I need to specify a https redirect url to the third party website to come back to my app. Right now when I am running my app on expo - I am using auth.expo to redirect to the app and it works fine.
Now, when I want to run it as an independent app, how should I set up redirection in it?
I have searched a lot for it and the solutions that I have found said to modify the AndroidManifest file which is not there in app created via expo.
Can you please guide on how should I proceed?

Json-server how to set a custom URL for the api

I am working on an app and used json-server for the backend api. I published the app using github pages and everything seemed to be working fine on my laptop. But when I try to open the app on another device, it does not work. I realized this was because I am using localhost:3001 as the resource for my api, and this only exists on my laptop. I am now trying to change the resource from localhost:3001 to a custom url 'https://my-json-server.typicode.com/vbrambila2/1RM/movements'. The issue I'm running into now is that the POST, PATCH, and DELETE methods in my actions aren't updating the api anymore. Anyone know what I might be doing wrong?

Network Request Failed when trying to upload formData using Expo

I'm trying to upload a formData using fetch API. I'm using Expo and my server is a feathersjs, with ngrok.
All other requests are working great, just those with formData files.
Trying with Postman also works perfectly.
I've noticed that this happened after I run yarn upgrade.
It seems to be an issue with Flippers on React Native 0.62.
So when I make the request it returns me the Network Request Error, but on the server side, it continues normally. But the problem is that I don't know when it finished on my server, so my Expo app cannot work accordingly.
If you guys don't know how to fix it, do you have any idea of a workaround that I can implement? As I said, on my server it still works perfeclty, but as my Expo App already returned an error, I can't work properly on my frontend. Should I make another request to look for the resolve of the file uploading?

Getting Socket.io to work in Android Webview

I am trying to use socket.io inside an Android Webview, inside a native Android app. The Android activity file has been updated with;
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("file:///android_asset/www/public/index.html");
My problem is loading the socket.io.js libraries from the index.html:
<script src="http://mydomain:port/socket.io/socket.io.js"></script>
The error I get during the rendering of the webview is:
XMLHttpRequest cannot load http://mydomain:port/socket.io... Origin null is not allowed by Access-Control-Allow-Origin.
I am using a node.js/express server to try and serve the libraries and thought I had configured this to accept cross-origin-resource-sharing (CORS) by setting
res.header('Access-Control-Allow-Origin', "*");
Now I am completely stuck! Can anybody recommend a way forward to get socket.io working in this configuration?
Cheers,
Kirbs
why not run service socket.io at activity, try my answer at this
singleton service socket.io
I using socket-io.java client library from github
Gottox