question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

URGENT - how to load https pages from remote server, and execute locally for nodejs usage?

See original GitHub issue

untitled presentation

Introduction:

We are doing a new research project recently with node-webkit see the above picture. Where node-webkit loads a simple https web url where we have all our nodejs scripts to access serial port, java-applets, tcp/udp etc etc to send and receive commands from a robot. after receiving all those information we need to send them to server, server does all the management and do a proper interpretation for the other robots to simulate same actions.

Problem:

But the node-webkit limitation is killing our project deadline because its not allowing very basic access when we load the pages using https / http instead of local.

We have our closed source code in cloud servers, all the node-webkit runs in Local machine and executes the web page as https://load-from-server, now we place all our device access codes in remote server instead of local and we need to have full access on that PC just like if you had the script executed locally. We also require this because our remote scripts get automatically upto date.

How can we make this possible in node-webkit, its a very important requirement for our use case but i have not found any solution for it yet.

Question: How can i tell node-webkit that following lines if loaded via https or http from remote server run them as it was running well using local index.html?

var gui = require('nw.gui');
var sys = require('sys')
var exec = require('child_process').exec;
var os = require('os');
var win = gui.Window.get();

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
rdtsccommented, Nov 24, 2014

@shamun: unless I’m misunderstanding your requirements, your problem should be easily solvable by providing the appropriate node-remote key in your manifest.

Assuming that your app lives on https://production.com you could do something like the following:

Client

package.json

To be shipped with the NW binaries, either standalone or packaged by itself inside app.nw, or similar.

{
  "name": "claw-client", 
  "main": "https://production.com", 
  "node-remote": "https://production.com"
}

⚠️ DANGER: node-remote can be dangerous if mis-used/configured. You should be as granular as possible when specifying which sources should have remote execution privileges.

Server

index.html

Located in /.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Claw App</title>
  </head>
  <body>
    <!-- OK as long as the origin satisfies one of the `node-remote` rules in your manifest. -->
    <script src="app.js"></script>
  </body>
</html>

app.js

Located in /.

// Shows usage in different JS contexts.
document.addEventListener('DOMContentLoaded', function() {
  // Native UI.
  require('nw.gui').Window.get().resizeTo(320, 320);

  // Core Node module.
  var uptime = Math.floor(require('os').uptime());

  // DOM.
  document.write('Server up for: ' + uptime + ' seconds');
});
1reaction
shamuncommented, Nov 24, 2014

That is the problem, we can not use index.html from local for many use policy. We need to use the index.html as https://load-from-server and have the same feature like running it from local index.html.

Is there any way use index.html locally but on the fly get the latest versions of nodejs script which can be injected from HTTPS SERVER at-least so that we do not have to always modify the index.html?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Create a Web Server in Node.js with the HTTP Module
When we bind our server to this host and port, we will be able to reach our server by visiting http://localhost:8000 in a...
Read more >
How to create an https server? - Node.js
To start your https server, run node app.js (here, app.js is name of the file) on the terminal. Now that your server is...
Read more >
How to download a file with Node.js (without using third-party ...
You can create an HTTP GET request and pipe its response into a writable file stream: const http = require('http'); // or 'https'...
Read more >
Rendering HTML Pages as an HTTP Server Response Using ...
Download Node.js and install it. Run node -v to test if the installation was successful. $ node -v ...
Read more >
Using Local Testing with Live | BrowserStack Docs
Test localhost websites ... Once you've enabled Local Testing, start a Live session, and enter the website address in the remote browser's address...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found