Meteor testing app using local server and custom ip - javascript

I'm developing an meteor application client/server and app, too.
when i compile my application using this command:
meteor run ios-device --mobile-server 192.168.2.126
App on device cannot connect to server (my server is on local network) and return this error in javascrip console:
Failed to load resource: Could not connect to the server.
If i use:
meteor run ios-device
it works perfecly.
Why?
I need to have application installed on different server in different network. The server has always the same ip: 192.168.2.126.. I need my client/app application works when is connected to one of my local network..

Solved, i have to use this format per server url:
http://192.168.2.126:3000

Related

How do I make my electron apps communicate locally between different machines

I have two electron apps. One is a server on machine1 and another is a client on machine2.
When I start the server from the electron app on machine1, I want machine2 (the client) to be able to be able to receive and send data to machine1 (the server).
I tried using http://localhost approach which works for the app during development but doesn't work for the packaged app which is installed on the machine.
Please help. Thanks
When you package an Electron app, it is no longer running on localhost, it runs on the IP address of the machine on which it is installed.
To establish communication between the server and client apps, you will need to use the IP address of the machine on which the server app is running. You can use the os module in Node.js to determine the IP address of the machine on which the server app is running. Once you have the IP address, you can use it to connect the client app to the server app.
You can also use a package like ip to get the IP address of the machine.
const ip = require('ip');
console.log(ip.address());
Hope this helps.

How to implement Socket.io with next.js without separate node server

I want to build a chat system with Next.js. I am not sure how I have to setup the socket server.
I want this to implement Next server not with a separate server.
Should I have to make a server.js file in root and run a server?
You will need to create custom server however, then you can't deploy to vercel, and you got yourself a regular nodejs application.
You could use cloud providers to handle sockets for you, or as you said, you could split your application to a regular next.js app and deploy your socket application separately.

How to handle backend API request for create-react-app bootstrapped app which is build and ran using "serve-s build" on AWS ec2?

I have create-react-app bootstrapped application which I build and then serve it to the static server using serve-s build. The React app is running on http://locahost:3000.
This app talks to my backend REST API(using java) which is running on http://locahost:8080.
Inside my React application, I have set axios.default.baseURL=http://localhost:8085/api.
Everything is fine on the localhost on my system. The React app talks to http://localhost:8085/api/xyz for CRUD operations and everything works great.
Now I have to deploy the project on AWS EC2 instance. The MySQL and REST API got deployed and rest API there is running on same instance on the port 8085 as http://locahost:8085. I have Apache server configured which sends the hostname(www.myxyzwebsite.com) to the http://locahost:3000 on the server. Everything is fine till now. The home page is visible on the browser.
Now, when the React app tries to communicate to the REST API from the browser, it is sending the request to the http://locahost:8085. Obviously, now the browser looks for some service running on port 8085 on my system and it couldn't find. Ideally, the request should go to the server with my hostname(www.myxyzwebsite.com/api/users/puspen). How to make this REST API call looks like an actual call like www.myxyzwebsite.com/users/pusp?
NOTE: Please note that this is not a server-side-rendered application.

How to connect frontend and backend on domain

I don't really have experience with backend and how things work together. I have created a simple live message sending app with node.js and socket.io. When I host a static web server on my machine (http-server which runs on local port using node.js) my app works perfectly fine but when I upload it on my host or github pages just for test, the backend doesn't seem to work. I uploaded all my files with an FTP program and the frontend loads fine but the backend doesn't. Do I have to know something like Django or ASP.NET to make these work on my host?
EDIT: One more thing, first line in my server.js is const io = require('socket.io')(3000)and in my script.js - const socket = io('http://localhost:3000')where 3000 and localhost:3000 stands for local host in my machine. What do i need to put instead of these?
You probably need to install and setup Node.js on your server, contact yout hosting provider for node installation if the option isn't available in yout cPanel.

Send get request to local api from react native mobile project

I am developing a mobile app using react native, SQL Server and NodeJS.
I got an API in my localhost. I run my application on an emulator and try to get request from API. But I got this message in catch(error):
[Error:Network Error].
Can somebody help me please.
Actually you are unable to access the local development server because port hasn't been forwarded by ADB yet. Try to replace the "localhost" with your machine IPv4 address and check else you can also try map your local server port just like React Native does.
To forward a port using ADB run the following command in your terminal
adb reverse tcp:8163 tcp:8163 remember this only works if you are using Android 6.0+.

Categories