Debug in WebStorm where the address is not localhost - node.js

I am trying to debug a project which needed a mapping in the hosts files from localhost to some other address like this
127.0.0.1 devproject.com
I can access the web app fine with a port number like this: devproject.com:3000 however this settings doesn't work when I try to debug in WebStorm?
Is there a way to tell WebStorm about this hosts file settings? Or I need to use a whole new settings? I am using node.js debug profile.

When debugging, you need using same URL as you normally use to access your application; so, to start debugging, you just need to specify http://devproject.com:3000 as URL in JavaScript Debug Run configuration. See https://confluence.jetbrains.com/display/WI/Starting+a+JavaScript+debug+session#StartingaJavaScriptdebugsession-Startingadebugsessionwhenusingadifferentwebserver

Related

Connecting to netlify on localhost with chrome and firefox

I am trying to follow this tutorial.
At 55:39 Ania is able to connect to her localhost:8888/.netlify port to see the records she has read from the graphql playground.
I am trying to do the same but cannot connect to the page. I have tried in both chrome and firefox and in both cases, I get a connection refused error message.
My firewall has permitted access for both chrome and firefox, and I even tried disabling the firewall. The error still returns.
I tried it without my vpn turned on.
I have logged into netlify (I have nothing on github yet, so it's just a local deployment).
Is there something special I need to do to be able to run local host with netlify?
The full text of the error message is:
This site can’t be reachedlocalhost refused to connect. Try:
Checking the connection Checking the proxy and the firewall
ERR_CONNECTION_REFUSED Check your Internet connection Check any cables
and reboot any routers, modems or other network devices you may be
using. Allow Chrome to access the network in your firewall or
antivirus settings. If it is already listed as a program allowed to
access the network, try removing it from the list and adding it again.
If you use a proxy server… Check your proxy settings or contact your
network administrator to make sure that the proxy server is working.
If you don't believe you should be using a proxy server: Go to
Applications > System Preferences > Network > Advanced > Proxies and
deselect any proxies that have been selected.
In relation to #1, I am connected to the internet. I can run the local host on port 3000 and get the react app to load. it does not read anything from graphql. When I console log the datastax data from the react app, I get null as a result (where Ania gets the records created in the first hour of the tutorial).
In relation to #2, chrome and firefox are both added to my firewall
In relation to #3, no proxies are used - except the box to use FTP Mode PASV is checked. I tried unchecking it but it makes no difference.
I tried adding the local host 8888 url as a Bypass proxy settings for these Hosts & Domains in my system preferences - but it makes no difference.
My console shows:
◈ Netlify Dev ◈ ◈ Ignored general context env var: LANG (defined in
process) ◈ Injected .env file env var: ASTRA_GRAPHQL_ENDPOINT ◈
Injected .env file env var: ASTRA_DB_APPLICATION_TOKEN ◈ Loaded
function getGenres
http://localhost:8888/.netlify/functions/getGenres. ◈ Functions server
is listening on 55302 ◈ Starting Netlify Dev with Create React App $
react-scripts start (node:55384)
[DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning:
'onAfterSetupMiddleware' option is deprecated. Please use the
'setupMiddlewares' option. (Use node --trace-deprecation ... to show
where the warning was created) (node:55384)
[DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE]
DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated.
Please use the 'setupMiddlewares' option. Starting the development
server...
Compiled successfully!
You can now view nextflix-datastax-clone in the browser.
Local: http://localhost:3000 On Your Network:
http://10.0.0.1:3000
Note that the development build is not optimized. To create a
production build, use yarn build.
webpack compiled successfully
ONE CLUE: I have cleaned my mac, I have cleared my cache (don't know why this would have worked since localhost 3000 loads the react app, but without the datastax data). A little box appears on my mac that says 'verifying AID.dylib'. I understand dylib means a shared database (maybe this some sort of Datastax reference? The process has been running almost 48 hours and the progress bar is at about 10%. Whatever that program is, it hasn't been verified. I wonder if this is why I can't load localhost:8888/.netifly in the same way that Ania can?
ANOTHER CLUE: I just found this post: https://github.com/netlify/cli/issues/3617 which suggests that Netlify can't read functions in v17. I don't know if that's still current. I'm currently stuck in my efforts to check if this is the source of the problem because my brew commands wont run in my terminal. I think this may be because of some incompatibility with the macOS Monteray upgrade that I just installed. I will update this post if I find a way to configure my computer to be able to follow a basic beginner's tutorial.

Debugging with node-inspector: Cannot GET /

I am running a Nodejs server with an application which I want to debug.
In order to achieve this using node-inspector I run the app as follows:
node-debug server.js
Unfortunately I can not access the webserver via URL anymore. Visiting http://127.0.0.1:8080 results in
Cannot GET /
However if I start the application the usual way with
node server.js
everything is fine (except for the fact that I can not debug). But I can access http://127.0.0.1:8080.
The '/' request is also not logged so it seems that it never reaches the server.
Hence the problem I have is: I can access the remote debugger via http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 but I can not start debugging because I can not trigger any action on the webserver via URL.
Oh and the debugger is not paused or anything. I skipped the first break point.
I resolved the problem by choosing a different port than 8080. It seems like the debugger uses this port. I was not aware of that because this port was familiar to me as I used it for my application.
As Schnodderbalken already answered, the problem lies in the application and inspector both using the same port 8080. If you tell inspector to use a different web port, 8082 for instance, the problem is solved.
You can do this by adding a parameter like so:
node-inspector --web-port=8082
You can then access inspector via http://127.0.0.1:8082/?port=5858

grunt-connect not working when host is 0.0.0.0

I'm trying to externally access my local node.js development server that's created using the grunt-contrib-connect plugin. The server works (locally) when I use localhost or 127.0.0.1 as the hostname parameter. However, when I change the parameter to * or 0.0.0.0 in order to allow external access (as specified in the documentation), I cannot access the server either locally or externally; this is the error I get in Chrome:
I've tried disabling my firewall and I can see packets coming in from my phone on the correct port (which I'm using to attempt to access my local server externally).
Any ideas why it doesn't work to use * or 0.0.0.0 as the hostname?
Figured it out - when I specified * or 0.0.0.0 as the hostname parameter, I was able to connect externally - I just hadn't tried since I wasn't able to access it locally and assumed it wasn't working at all. Changing the address in the browser to localhost:9000 (instead of 0.0.0.0:9000, which it defaults to) when Grunt first opens the page allowed me to access my server locally.
You can set your own ip address instead of the 0.0.0.0.
With this grunt launch the server on your ip. You can use your mobile to.
The livereload will work on your desktop and on your mobile.
It's not the best way if your work by team because each one have his ip address but it's good enough if you work alone.

Node.js Proxy for out going calls

I am trying to create a local mockup server for an iOS app. I have a running deployed server like url: "http://some-running-server.com/" I would like to be able to use a local http://127.0.0.1/getuser using node.js.
In the app i would user http://some-running-server.com/getuser
I have seen "Charles" application can do this. Maybe someone have done this in Nodes, so you a able to test agents a local mockup using only node.js?
Thanks
Regards
Setup your browser to use 127.0.0.1 as a proxy (network settings), then run your code on localhost (127.0.0.1) and respond to the request. The url can stay the same as the original one. You can use node-http-proxy to forward the request to the original server, if you want to.
You can add the url to your hosts file. If your on OSX or Linux you can find it in etc/hosts. On windows the file is at %systemroot%\system32\drivers\etc\ just map the url to your local IP
127.0.0.1 localhost
# mapping some-running-server to localhost for development
127.0.0.1 http://some-running-server.com
Just remember to remove the entry when you go to production!

How do I, in nodejs, set up a Mongo viewer (like Mongo-Express) on the same port as my main app?

I'm new to just about everything with regards to nodejs and Mongodb but I managed to get a simple app up and running and now I want a database viewer. I found Mongo-Express and installed it on my localhost where it works fine. The viewer is configured in a config file with host a baseUrl and port.
The problem is on the live server (AppFog) where I only have one port available which is occupied by my main app. How do I solve this issue? Can they run on the same port or is there another viewer available that doesn't need to run on a separate port?
I can recommend MongoMate which can either run as a standalone MongoDB Browser or (what you want) it can be mounted within an Express app. See the webpage for more info.
PS. I built MongoMate :P

Resources