Call an API from web browser to the localhost of Electron app via WebSocket - node.js

I've made an Electron application as a server to receive API requests on the user's PC. Then I've allowed users to request API from the browser (not only on the same PC) to Electron application localhost server. To make it work, I've used Ngrok as a tunnel to publish my local port, but because of the limitation for free users, I could not use it anymore.
I'm aiming to solution calling localhost via Web Socket, but I could not found anyone attempted on the Internet.
Could you please give me some idea to deal with it? Thanks in advance.

Related

Is there local Accepted Tunneling Solution To Test Facebook Webhooks

I am integrating WhatsApp with Django application that I am still running locally to send WhatsApp which is working fine.
However to receives messages from Facebook it needs a webhook that I have implemented using Django since I am still building the application locally. on my laptops I am using Tunneling solutions Ngrok and LocalTunnel to expose the application online so that Facebook can send incoming messages to my App onto my laptop but Facebook is rejecting URLs that are I created using Ngrok and LocalTunnel with error message below:
The url https://2y7y-56-897-3-457.eu.ngrok.io/apv/facebook has been identified as malicious and/or abusive.
The url https://great-finds-comes-78-673-8-897.loca.lt/apv/facebook has been identified as malicious and/or abusive.
I have two questions:
Has anyone been successful using Ngrok and Localtunnel while building locally on Facebook webhooks?
what other tools are there that are available on windows to achieve this? I don't have a dedicated domain name yet and dedicated cloud/online platform where I can host the app yet.
The other alternative solutions I have seen that have been mentioned, it's the Ultrahook though the client is available as a Ruby gem that I have failed to get running on windows:
I was following this question: Can i use localhost as a URL Callback in a messenger webhook

How to not show PORT from Nodejs API Requests

I was working in a project and sudden noticed that while react is calling node api, i can see port number also in console network, which i think is not secure.
So is there any tool, settings whcih we can use to hide ports from api calls.
I am using apache as server, node api and react frontend.
Thanks
Tried virtual host settings but not worked

Node.js web gui access external node.js web server

I have a node.js web gui and server running on a localhost port and another node.js web server running on another localhost port. I haven't been successful locating an example of access the 2nd web server from the 1st. I want to post a "GET" to the 2nd server and have it respond with the piece of data using XMLHttpRequest. Does someone have an example of something similar? Or is this even feasible?

beginner webrtc/nodejs issue connecting remote clients

I'm trying to develop a web application in nodejs. I'm using an npm package called "simple-peer" but i don't think this issue is related to that. I was able to use this package and get it working when integrating it with a laravel application using an apache server as the back end. I could access the host machine through it's IP:PORT on the network and connect a separate client to the host successfully with a peer-to-peer connection. However, I'm now trying to develop this specifically in node without an apache back end. I have my express server up and running on port 3000, I can access the index page from a remote client on the same network through IP:3000. But when I try to connect through webrtc, I get a "Connection failed" error. If I connect two different browser instances on the same localhost device, the connection succeeds.
For reference: i'm just using the copy/pasted code from this usage demo. I have the "simplepeer.min.js" included and referenced in the correct directory.
So my main questions are: is there a setting or some webRTC protocol that could be blocking the remote clients from connecting? What would I need to change to meet this requirement? Why would it work in a laravel/webpack app with apache and not with express?
If your remote clients can not get icecandidates, you need TURN server.
When WebRTC Peer behind NAT, firewall or using Cellular Network(like smartphone), P2P Connection will fail.
At that time, for fallback, TURN server will work as a relay server.
I recommend coTURN.
Here is an simple implementation of simple-peer with nodejs backend for multi-user video/audio chat. You can find the client code in /public/js/main.js. Github Project and the Demo.
And just like #JinhoJang said. You do need a turn server to pass the information. Here is a list of public stun/turn servers.

Get db results from (node - express - mongodb) to angular 4 securely

There is no issue b/w establishing connection b/w nodejs & angular. Also the database results are fine. This is the only problem I'm facing now.
I have 2 different ports but same server
0.0.0.0:3000 - for nodejs
0.0.0.0:4200 - for angular
When I make an api request to node(mongodb) from angular it is visible in browser console as well as networks tab when I inpect. How can I overcome this ?
You can't. Angular is an SPA, a framework that works on front-end. Which means once the files of the application downloaded in the browser memory, it then launch the instance of your application.
Afterwhat, when you make a request to an API or any other URL, the browser behaves as it should : it makes the request. You have no real way to prevent this.
That doesn't mean the requests are not secure. Viewing requests made by your app in the console or the network tab doesn't mean it's not secure.
you can use nginx as a proxy server to redirect your all REST call to overcome this.
for detailed use please visit here nginx

Resources