Getting the node.js monitor-dashboard project to work externally - node.js

I'm trying to get the monitor-dashboard project to work but i get a page can't be found error when I try to use a browser externally.
http://lorenwest.github.io/monitor-dashboard/
Internally seems OK, I'm getting a HTTP/1.1 200 OK from http://localhost:4200 with the usual curl command.
I went in to node/node_modules/monitor-dashboard/config/, and changed default.js and external.js and changed all occurrences of allowExternalConnections to true.
I've also got node-monitor loaded in to my node project.
I'm running node server.js first and then npm start monitor-dashboard in another window.
port 4200 is open via iptables -L
Any ideas?

The setting you're looking for is:
export NODE_ENV=external

Related

Connection refused on localhost

I am trying to work on my nodejs and reactjs app at school but everytime I run the server, I get an error with
localhost:PORT/net::ERR_CONNECTION_REFUSED
Is the wifi refusing the connection on localhost?
PS: The react side renders correctly
If you're using WSL (linux on windows), restart its service LxssManager Servie (run services.msc) and try again.
Try changing the url from localhost to 127.0.0.1 . If it works, then it means your environment is not resolving localhost to 127.0.0.1
Or Try with changing the PORT Number
For those of you that the approved solution didn't work for (changing localhost to 127.0.0.1) I was able to fix this just by restarting my computer. Not sure what caused the issue but the day before today my app was working fine and then today I got hit with this error. Restarting fixed the issue.
In my case I have an error with require in setupProxy.js
In my case, deleting the node_modules and then reinstalling using npm install worked.
I was also facing this problem on mac m1 from last 2 days, so finally i ended fixing the issue by :-
Run 'npm start' from default shell(/bin/bash) on vs code.
You can also try to update the node version.
You may need to change the port for application only if some other application is running on default port(3000)
In my case, I resolved the issue using "npm start" command again in terminal of vs code and it works.
In my case I had made changes to the setupProxy.js that caused the problem. Try reverting back to something that is working, such as:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
Rebooting the system (linux) worked for me. Consider rebooting first.
the problem of "localhost refused to connect." is occur because of command prompt that you closed so you must keep open your command prompt after hit "npm start" command till you work in "App.JS" file.
i'm sure this will work 100%.

ForestAdmin: Unlock your data. CORS configuration issue

I try to install ForestAdmin but get an error after set up my account and generate my lumber db.
What I did :
lumber generate -c 'mongodb+srv://ugo:<my-password>#tlf-qraep.mongodb.net/test?retryWrites=true&w=majority' test
cd test
npm install
npm install lumber-forestadmin --save
lumber install lumber-forestadmin --email <my-mail> --projectName test
npm start
I got this message so I clicked on it
Your admin panel is available here: https://app.forestadmin.com/49189
I re-entered my password but I got this error message :
"Unlock your data
Oops, cannot reach your application. Are you sure it is running? If your application is running, you might have a CORS configuration issue."
I checked and my server running on port localhost 3000.
Someone already got this error message?
Thx for the help guys.
I finally succeed to remove the error. I generated a new lumber on an other port (3003 rather than 3000) and it worked for me !
Maybe another app is using the 3000 port ?

How to get `browser-sync reload` to use https

I've a browser-sync instance serving my app, which uses bs-config.json and within that configuration file I specify https and a cert and key. Later, I need to manually force a reload by calling browser-sync reload; however, this call results in a "socket hangup". I believe this error occurs because browser-sync reload is posting to the default port and http. I tried passing the same config to the reload call, but that doesn't change it. I also tried using command line switches and specifying https: true, which doesn't work either.
How can a command-line call to browser-sync reload work when using non-default settings?
So I recalled a way to work-around the problem and then found info and a proper solution:
work-around: curl --silent -X POST https://localhost.test.com:3000/__browser_sync__?method=reload
bug-info: https://github.com/BrowserSync/browser-sync/issues/1235
proper solution: browser-sync reload --url https://localhost.test.com:3000

http-server : how to set the root directory of my server?

I run a server via node's http-server module. Trouble is, it displays the working directory /document/js/ :
# /document/js/server.makefile
node ../node_modules/.bin/forever ../node_modules/.bin/http-server --cors &
# localhost:8080 shows content of /document/js/
I actually want my server to show the content of /document.
How to set the root folder of my server (/document/js/server.makefile) so localhost:8080 displays the content of /document/ ?
The http-server docs usage states that you can pass in a path before your options. So in your case, you might want to try something like:
hs /document [your_options]
Add -o to open your browser after starting your server.

Node.js, WebSocket Location Issue?

I created a server using Node listening on port 8000, localhost. Verified it's running properly, but I cannot access the WebSocket on the client (Chrome 5). Tried several implementations from various Git repos, node + websocket, socketIO, articles, etc. Nothing.
No port conflicts (sudo lsof -i tcp);
Tried server.listen(8000, "*");
Pointed to ws = new WebSocket("ws://:8000/test");
Debian Lenny, Apache22
Node v0.1.98-31-g1c6671a
I'm thinking there may be a conflict with url rewrite. Or possible permissions. Any ideas?
I had a similar issue on Ubuntu 10.04 LTS 32-bit and Chrome 5.0.375.125 and found out it is a bug in Chrome.
Here's how you can test and work around the problem. I used WebSocket with PHP and later Node.JS:
PHP: Download a tutorial file from http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ and extract it in a folder called 'socket' in your webroot. This folder now contains a readme.txt and the folders 'server' and 'client'. Now start the script in the console according to the readme (for me the command was: sudo php -q /var/www/socket/server/startDaemon.php ). It should print 'Start listening on Socket.' . Leave the console window open. Now go to localhost/socket/client/client.php in Chrome. It should say 'Socket Status 0' and if you look in the console you see no new messages (no connection was made).
Now here comes the trick: open a second Chrome tab. Point this tab to the same url: localhost/socket/client/client.php (It also says 'Socket Status 0'). And then close it again. Your original tab should now say 'Socket Status: 1 (open)' and in the console you see a handshake was made. WebSocket now works.
I repeated the same trick as above but this time using Node.JS with the Socket.IO script. The chat example included in Socket.IO-node ( github.com/LearnBoost/Socket.IO-node ) had the same issue, hanging at the 'Connecting...' stage. Opening a second tab to the chat box and then closing it again solved the problem and the chat box proceeded to load properly. The Node.JS server confirmed the connection in the console. From then on WebSocket worked fine.

Resources