How to connect IOS Expo GO to localhost on another machine - reactjs

So I'm starting to learn react-native and wanted to test some graphql queries within it, but I can't quite get the hang of it.
I'm hosting a localserver on a notebook running ubuntu 20.04 and I'm trying to do the requests via an Iphone through Expo GO. I should say I can query my graphql server directly via the iphone browser, it's just inside the app that it doesn't work.
I've tried a lot of things I saw on similar questions, like disabling the firewall and putting the machines local ip at the graphql client, but none worked.
I've set up my apollo-client with the IP like this:
The query I'm trying to run just returns a string and this is how I'm calling it:
I can see the query is working through the web view for the app on the same pc the server's running, but just cant get it to render at the Expo GO thing.

Related

How to deploy a simple json-server?

I completed an online React course and deployed my application to Heroku. During development, I used the 'json-server' module found at https://github.com/typicode/json-server. This served up a folder on my computer which contained a simple json file and a few images for my website while conforming with the REST API. What do I need to do to get the server to operate independently of my machine so that my application can fetch the data ? I have zero experience doing this.
if you mean you want to create a server for your site,
first of all, you need to get a server, which can run nodejs , then you need to deploy and run your JSON server via a nodejs(express) app.
then you can connect to your server via your website/app
in order to do these things, you can follow tutorials
there are lots of tutorials about it.
hope you got the idea.

VueJS PWA says Network Error in my small PWA. Even I can't login

In my PWA everything is working except POST HTTP calls. I have a login on my first screen. It says Network Error. But it works fine Desktop/Laptop web browser. Only found the problem on mobile app [Android]
Note
I used Vue CLI for creating project.
I also tried with React. Happened the same. I don't know what's wrong with me.
You most likely try to connect to localhost. When deploying to a different device localhost is the actual device you are deploying and most likely you are not running a web server there.
You need to find your local machine's ip and use that as base url for HTTP calls.

EXPO React Native App Won't Load From Windows

Hi all,
I am starting a project with one of my team members. Our goal is to create a React Native app with Expo. This isn't the first time I've used Expo or React Native.
The problem:
I use Ubuntu 18.04 and my friend uses Windows 10. As usual Windows is screwing something up. When my friend runs expo start in the same project as me he won't be able to connect to the project from his phone, not am I. But when I start the Expo project with expo start everything works just fine for both him and me.
After testing everything we came to the conclusion that it is not his/my phone or internet. It is his machine that is blocking something and we don't know how to resolve it.
We've tried old projects that run fine on my machine with both phones.
We've tried multiple devices and internet connections.
We've tried turning of all firewalls on his machine.
I posted the original help request on Expo Forums.
I hope someone is able to help!
I found out what the problem was. It seems to be VMware/Virtualbox.
Here is a quoted solution which I found here.
Solution for windows 10.
Go to cmd and write ipconfig. Look what is
the first Ethernet adapter. It should be Ethernet adapter Ethernet. If
it is not and it is something like Ethernet adapter Virtualbox... Then
this is the problem voalaa. Expo is taking the ip adress of the
virtualbox. So go to "Network connections" right click on the adapter
you want disable and change the status to disable. Connect you
computer to ethernet and you phone to the same wifi network. Restart
Expo, then the default url should be changed. Select host->lan, start
the app and then -> run on android. That's it.
I hope that this will help other people!

Using Swagger to Manage Microservice Architecture Across IIS Express

I'm coming into an existing application where a single React application exists that calls multiple APIs. The APIs are written in .NET Core and I've been instructed they are typically hosted with IIS Express when debugging locally.
Where I'm running into trouble is understanding how the React application will hit the backend API projects, when the API projects are running on multiple IIS Express instances that don't have static ports.
For instance, I'll hit "run" on the React project which launches the React application along with a controller that might be running on localhost:5888. I can easily hit the controller from the React application using window.host + /Controller/ which will handle resolving the port for me. However, if I "run" another API, from a separate Visual Studio instance, it'll get hosted on a random port, something like localhost:5889. If I try to hit that API with window.host + /SecondAPIMethod/ from the React application, it'll come up with a 404 error, because the React app doesn't know what port the IIS express instance with the second API is running on.
I've been told by coworkers that Swagger is the key to managing this, but I'm unsure how.
It is not running on any random port. Port number is specified in the project properties. When you are debugging in visual studio, you can set the port number by going to project properties -> debug -> App URL.
When you deploy the web api on IIS Server, it will run on the port you have specified when configuring the web api.
Now when you know the web api (with port number) in advance, you can hard-code the url or put it in app settings file of your react app. Hope this helps.

ReactJS app on SSL

I'm very new to ReactJS and am trying to test deploying to a web server.
It's just one component that says hello, to make sure everything is working.
It works fine on local host, but when I upload to my webserver, which is configured for SSL, it does not work.
Works: http://careigniter.com/x/test/
Does Not work: https://careigniter.com/x/test/
Is there something special you have to do if you are going to serve the entire app under SSL?
Thanks!
The issue is that server has wordpress and some caching, that is probably what is going on. I should have just started on a fresh server to begin with.

Resources