PS. Those 42 lines are all the source code.
That’s it.
No scaffolding. No npx create this-or-that.
1. Create a folder called toast.
2. Add those 42 lines of code to a file called index.page.js in that folder.
3. Run kitten¹.
Now hit https://localhost in your browser and you will see the example running just like in the video in the first post.
:kitten: 💕
¹ https://codeberg.org/kitten/app
# Kitten #SmallWeb #StreamingHTML #web #dev #htmx #hypermedia #WebSocket #html #css #JavaScript #toast
@aral Why do you need https://localhost though? Browsers recognize http://xyz.localhost:port as a secure context, so if you properly use relative urls you can switch from such a local dev env to https://real-domain.org when in production with no hassle.
@alexmorse To be fair, you’d still need a local web server. My point wasn’t about treating file:// URIs as if they’re being served by a server but for giving developers the option to have their https://localhost routes treated as trusted without having to mess with local development certificates and creating local certificate authorities and having them added to browsers.
@mdhughes Hey Mark, that runs an http server at localhost:8000 not a server at https://localhost.
I hate to link to this Google site, but here’s a good overview of the use case: https://web.dev/how-to-use-local-https/
It’s mind-boggling to me the hoops we have to jump through to get https://localhost working for #web #development.
Browsers should just show a pop-up: “Are you a web developer using https://localhost for testing? If so, we’ll treat it as trusted. If you don’t know what this means, answer No. [Yes, No]”
And boom. If you answer yes, you can test with https://localhost without requiring mkcert, certutil, etc.
(Until then, you can use https://codeberg.org/small-tech/auto-encrypt-localhost in your #NodeJS projects.)
076萌SNS is a social network, courtesy of 076. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.
All 076萌SNS content and data are available under the Creative Commons Attribution 3.0 license.