Live data from Hacker News

I wrote a static web page and accidentally started a community (2023)

localfirstweb.dev

51–60 of 136 posts

Re: I wrote a static web page and accidentally started a community (2023)

#51
post #44

Earlier quoted context omitted.

Luckily, starting a local HTTP server for development is more-or-less a one-liner for a long time, in most OSes (maybe even Windows might ship with Python nowadays?): python -m http.server 8080 If if you're stuck with python2 python -m SimpleHTTPServer 8080 At least this doesn't introduce the security issues you'd see with any file:// resource being able to load other file:// resources

It's not perfect either: https://docs.python.org/3/library/http.server.html#http-serv... You should also add a `--bind 127.0.0.1` so you don't expose the site to everyone on your network.

Yeah, that's a good callout, thanks. Not sure why they took the less secure approach for something that is intended as a development environment, but I think I feel like that for lots of decisions in Python so maybe not that weird in the grand scheme of things.

Re: I wrote a static web page and accidentally started a community (2023)

#52
post #22
post #6

Hey browser makers, please allow file:// URLS to actually be able to load other files in the same directory without giving a CORS error. You can't even run a JS file from the same directory! That's what's really killing "local first".

As usual, this sounds great for the nice players. Unfortunately that means if you download an html file and double click on it then it can send anything in your downloads folder to anywhere else.

Download HTML file (and dependencies), open local file, local JS requests from internet, and CORS error. Why can it not work like this?

Re: I wrote a static web page and accidentally started a community (2023)

#53
post #6

Hey browser makers, please allow file:// URLS to actually be able to load other files in the same directory without giving a CORS error. You can't even run a JS file from the same directory! That's what's really killing "local first".

I think at one point Firefox used to let you open a directory and start a web server in said directory for this very reason.

Re: I wrote a static web page and accidentally started a community (2023)

#54
post #21

Earlier quoted context omitted.

That requires having an actual server though.

which is extremely easy to do. Most programming languages have a one-liner to do it.

But then I want my non-technical users to experience the same benefits. So I guess I’m building an app with a web server included.

Re: I wrote a static web page and accidentally started a community (2023)

#55
I built and offline friendly app, was not offline first, but it was my first PWA, the idea was that a pilot could have our web page open at high altitudes, potentially with bad service, and they could still interact with anything, once back online, it would push any changes they made. I implemented it with vanilla JS.

The only annoying part was detecting when the browser was back online, I used some hacky solution since there was no native API for it for any browser at the time, but it worked.

Re: I wrote a static web page and accidentally started a community (2023)

#56
post #22

Earlier quoted context omitted.

As usual, this sounds great for the nice players. Unfortunately that means if you download an html file and double click on it then it can send anything in your downloads folder to anywhere else.

Download HTML file (and dependencies), open local file, local JS requests from internet, and CORS error. Why can it not work like this?

> local JS requests from internet

I really don't understand what this means.

Re: I wrote a static web page and accidentally started a community (2023)

#57
Another aspect of local-first I'm exploring is trying to combine it with the ability to make the backend sync server available for local self-hosting as well.

In our case we're building a local-first multiplayer "IDE for tasks and notes" [1] where the syncing or "cloud" component adds features like real-time collaboration, permission controls and so on.

Local-first ensures the principles mentioned in the article like guaranteed access to your data and no spinners. But that's just the _data_ part. To really add longevity to software, I think it would be cool if it would also be possible to guarantee the _service_ part also remains available. In our set up we'll allow users to "eject" at any time by saving a .zip of all their data and simply downloading a single executable (like "server.exe" or "server.bin"). The idea is you can then easily switch to the self-hosting backend hosted on your computer or a server if you want (or reverse the process and go back to the cloud version).

[1] https://thymer.com/

Re: I wrote a static web page and accidentally started a community (2023)

#58
post #49

Earlier quoted context omitted.

I guess the main disadvantage is you can't reliably link to anything. Maybe not a problem if you only ever need one local server.

Maybe this is an opportunity. Is there already a “DNS for ports” whereby the hosts file is propagated with application process identifiers that are mapped to localhost:port in hosts file?

Careening back to inetd and /etc/services …

Re: I wrote a static web page and accidentally started a community (2023)

#59
post #56

Earlier quoted context omitted.

Download HTML file (and dependencies), open local file, local JS requests from internet, and CORS error. Why can it not work like this?

> local JS requests from internet I really don't understand what this means.

If you load a file using the “file” protocol, it shouldn’t be able to load other resources (JS from the internet) with non-file protocols to protocols (http, https, etc.) to non null-string domains. because that would violate cross origin request sharing (CORS).

I too like local HTML and would love to see it restored without requiring a local server. If I spin up a local Webrick to serve anything from my file system, I’m no better off (except maybe that it’s scoped to a particular directory and children).

Re: I wrote a static web page and accidentally started a community (2023)

#60
post #44

Earlier quoted context omitted.

Luckily, starting a local HTTP server for development is more-or-less a one-liner for a long time, in most OSes (maybe even Windows might ship with Python nowadays?): python -m http.server 8080 If if you're stuck with python2 python -m SimpleHTTPServer 8080 At least this doesn't introduce the security issues you'd see with any file:// resource being able to load other file:// resources

It's not perfect either: https://docs.python.org/3/library/http.server.html#http-serv... You should also add a `--bind 127.0.0.1` so you don't expose the site to everyone on your network.

That should really be the default behavior.
Post reply on HN