Accessing files from localhost

Hello there

I think I might be missing something obvious here, but I'm having trouble accessing files using localhost from the dashboard ui?

I have a link to a video file on one of the pages which plays when I click on it (the file is saved in the static folder on the same machine as node red).

If I use localhost or 127.0.0.1/ it doesn't work, but if I use the external ip address it does.

This doesn't happen with non dashboard nodes.

As ever any help would be much appreciated.

Kind regards

Paul

Won't you have to also include the path to the file to get to it, rather than just the IP address?

That is because Dashboard is actually running in your browser whereas Node-RED and its nodes is running on your Node-RED server. So you do need the actual IP address of the server if accessing via Dashboard but the localhost address if accessing via Node-RED flows.

But when you configure Node-RED's static folder, what you put in there is made available via Node-RED's ExpressJS server the same as Dashboard. So from a browser on a different device, you use the external address.

Hope that makes sense?

Hi there

Thankyou very.much for the explanation, it does indeed make sense.

Kind regards

Paul

Hello (again) TotallyInformation

Please, Please Help!

I had pretty much finished the project I was working on until I encountered this problem, and now I realise it's pretty critical.

If I could explain in slightly more detail, you might be able to point me (further) in the right direction.

If you have a webpage on a server and you want to display a video, I understood that you could reference the source as the local file path relative to the index/root, say "/videos" or something. So wherever you happened to viewing the webpage from it would still understand that local file path.

That is what I would like to do with my flow/dashboard.

At the moment, as you suggested I changed localhost to the external ip address which works fine, but I need to be able to make remote connections to the dashboard which is the problem now

At the moment I use pitunnel to remotely connect to my raspberry pi on the node red port 1880 which works fine, but now the external ip address doesn't work (which I guess is obvious).

What I thought I should be able to is reference the file path "home/pi/videos" or something, like you would do with a website, to bypass this problem.

If you suggest any possible solutions, I would be very grateful

Kind regards

Paul

No, not so I'm afraid. THe URL has to be relative to the web server and not anything to do with the filing system except that, something like Node-RED's static folder exposes a specific folder as the / URL (unless you change the httpNode setting) and so any sub-folder in that static folder is represented in the URL. So lets say that you set your static folder to /somewhere/ then add a file one.mp4, and you are running node-red on a device with an external (to your local network - ignore the Internet for a sec) IP address of 192.168.1.10, then the URL will be http://192.168.1.10:1880/one.mp4. If you then add a sub-folder /somewhere/my-videos/ and move one.mp4 to there, the URL becomes http://192.168.1.10:1880/my-videos/one.mp4.

Now, with pitunnel, you are creating a special kind of VPN. THe pitunnel service gives you a web address. From their marketing blurb:

Access HTTP tunnels on your own custom pitunnel subdomain. Share your tunnel URLs with friends and family to give them secure access to your projects.

More importantly, since you should NEVER expose anything to the Internet without encrypted links:

Tunnel traffic, web and terminal access securely encypted using TLS & HTTPS.

So the service should give you an external address that you map, via a "tunnel" to the internal address of your Pi. The internal part of the tunnel will be localhost:1880 if you are running the pitunnel application on the pi itself (or 127.0.0.1 if it doesn't let you use localhost) and the external part will be whatever the service lets you set. It doesn't expose its documentation without a login so I can't really help there.

Thanks a million TotallyInformation

It was very lind of u to reply so quickly and thoroughly.

I will take another look at pitunnel.

Cant believe i have essentially misunderstood the internet ! slight_smile:

I guess the simpliest solution would be to get a 3g sim with a public ip address and just take pitunnel out of the equation?

Thanks again

Paul

Not really, by doing that, you will be taking all the protection away. Not a good move. Best to get pitunnel or an alternative such as NGROK working.

oh ok, in that case I will persevere with pitunnel.

Many thanks again

Paul

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.