tapio / live-server

A simple development http server with live reload capability.
http://tapiov.net/live-server/
4.4k stars 484 forks source link

Live-server links to local files do not work #409

Closed amine-aboufirass closed 1 year ago

amine-aboufirass commented 1 year ago

Issue description

I'm trying to a href to a local folder. Typically I would do something like this: <a href="C:\Users\aa\Desktop ....>. If I just open index.html with chrome, I'm able to navigate to the link and view the contents of the folder. However if I navigate to my live-server instance the link does not work. How can I get live-server to allow local folders/files?

Software details

amine-aboufirass commented 1 year ago

I also notice that img srcing local files does not render the image. If I open index.html outside of live-server the image shows up just fine.

akx commented 1 year ago

You don't – the live-server page has a "http" origin (even if it's a local address), and it would be a security vulnerability if a random HTTP origin page could access C:\Users\aa\Desktop.

amine-aboufirass commented 1 year ago

@akx Yes, after some reading I realized that this was by design, and done for security purposes.

My use case however involves live-refreshing a page so that I can see the changes on my browser as I work on the HTML. The HTML does contain images and local links.

Is there perhaps a workaround to get something like this to work with Live Server?

amine-aboufirass commented 1 year ago

@akx (or someone else) how can we include images in the html document and still have it render in live-server?

akx commented 1 year ago

@amine-aboufirass Just put those images in the same folder that's being served by live-server and refer to them with their names only.

amine-aboufirass commented 1 year ago

@akx I see, I was invoking live-server with live-server test.html. In fact I should be invoking it with live-server . for the image to work.