> SPA_MODE when set to 1 404 request will return /public/index.html as a 200. oof, as someone who frequently has to run DAST tools, returning a 200 for something that should be a 404 is the bane of my existence. The tool will try to request sensitive files by trying something as simple as fetching hxxps://example.com/../../../etc/passwd. If you return a "200 OK", it will flag as a security issue, even if the resultin…
But if it's an SPA, how else would you handle this case? How is the webserver supposed to know in advance which URLs the SPA is able to handle?
Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
51–60 of 119 posts
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#52By the way, is there a really minimal, really fast, reasonably secure, zero-cofig single-binary web server which would only support HTTP GET and just expose all the static content in a given directory over it?
Not sure what single binary means but here’s my take. https://github.com/dclowd9901/posse
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#53Earlier quoted context omitted.
But if it's an SPA, how else would you handle this case? How is the webserver supposed to know in advance which URLs the SPA is able to handle?
I typically keep all my SPA routes/route names in a single JSON, and then reference those from the App, instead of repeating the routes everywhere. I can then pass those to the server to let it know what the SPA can handle.
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#54> SPA_MODE when set to 1 404 request will return /public/index.html as a 200. oof, as someone who frequently has to run DAST tools, returning a 200 for something that should be a 404 is the bane of my existence. The tool will try to request sensitive files by trying something as simple as fetching hxxps://example.com/../../../etc/passwd. If you return a "200 OK", it will flag as a security issue, even if the resultin…
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#55Earlier quoted context omitted.
I just figured any savings where savings can be made is a good thing, especially if there are zero downsides, plus it means very low CPU usage as it's literally just pulling from RAM without any CPU usage. It also precaches gzipped and brotli'd versions of sensible files so that it can accept-encoding for a variety of browsers.
Couldn't the extra memory copies end up being an actual downside? I.e. the sort of thing that inspired sendfile(2) usage in some servers?
I see it as a pragmatic trade off between speed and RAM. Even free tier EC2 instance should have enough RAM to handle pretty much any SPA even if the text content is duplicated (compressed) especially seeing as with a unikernel you have no RAM used up by Linux processes.
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#56Considering the latency between the user web browser and the server, does the “extremely low latency on account of caching all files in memory” really matter? The files should already be cached by the OS and using sendfile lets the OS copy the file directly to the network.
> serving things like Astro from S3 Given that point, I got the impression that the comparison was against loading resources from S3. The difference between that and serving from memory (even between that and serving from uncached traditional hard-drive) is going to be significant. EDIT: cursory research suggests S3 latency ( https://stackoverflow.com/a/861539/114292 , being the most recent reference that turned up)…
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#57I like the idea! Have you seen redbean, which is a universal binary and serves static files from a zipfile? How does this compare to that? Honestly, I think that the current Web can easily use libp2p from IPFS and serve files from any browser peer to peer, with relays on the internet. I think the Web lacks two major things: 1) Address resolution only uses federated DNS and you need extensions to use, say, self-sovere…
Federation’s a non-starter when most devices people use are battery powered and don’t like to hold connections open when idle. Like, it works, but it won’t work well enough unless most devices are just going through gateways, which largely defeats the point.
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#58> SPA mode to service 404s as index (200) to support client side routing. Be careful: SPAs can handle 404s client-side. All you need to do is continue to return the 404 result code and include the same exact content that you normally do. Then your SPA recognizes that the route isn't set up and displays the error page.
Yep, returning the wrong HTTP status code is going to confuse a lot of search engines, chat app link previews, and other automated consumers of your SPA, even if you subsequently display the correct error page.
How is the search engine going to find a page that doesn't exist, isn't in a sitemap, isn't linked to in any nav anchors, in order to index it?
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#59Earlier quoted context omitted.
Couldn't the extra memory copies end up being an actual downside? I.e. the sort of thing that inspired sendfile(2) usage in some servers?
I’m not so sure, if you’re serving massive files this is not perhaps the option you want. If your SPA is so big you can’t handle a container that has its app code and assets in RAM perhaps it’s also too large. I see it as a pragmatic trade off between speed and RAM. Even free tier EC2 instance should have enough RAM to handle pretty much any SPA even if the text content is duplicated (compressed) especially seeing as…
Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs
#60By the way, is there a really minimal, really fast, reasonably secure, zero-cofig single-binary web server which would only support HTTP GET and just expose all the static content in a given directory over it?
Caddy [1] is a single binary. It is not minimal, but the size difference is barely noticeable. serve also comes to mind. If you have node installed, `npx serve .` does exactly that. There are a few go projects that fit your description, none of them very popular, probably because they end up being a 100-line wrapper around http frameworks. [1] https://caddyserver.com/