Comments (9)
One thing to add to this - for those using a ServiceWorker for more than just offline (push, caching, etc), it's less optional during development.
from preact-cli.
@gokulkrishh I don't think it's the certificate specifically, but simplehttp2server
will redirect HTTP to HTTPS (see GoogleChromeLabs/simplehttp2server#16). The browser will remember the Upgrade-Insecure-Requests
header & continue that behavior for the same localhost:port
combination.
You will have to empty cache in order to fix this.
@prateekbh @developit Found a good summation of why I (still) think SW should be off by default: https://twitter.com/dan_abramov/status/869165916378075136
from preact-cli.
Hmm... Looks like the cert error should be a separate issue (you're not the first with this, although it works for me). Once that's resolved, the npm run serve
will register a SW for you.
But, this is about locahost
blocking ๐
My main point from last night was that I don't think offline caching should be on by default for development/HMR. We may ofc disagree on this, but I've seen this cause more confusion for the average developer who may not have SW experience. Of course, there's no problem using SW in dev if you're familiar with SW & what behaviors it implies.
@developit suggested in Slack that we could specify when the CLI should enable the offline behavior. I'm a fan of this!
Taking that suggestion & my personal off-by-default preference, we can pass a --offline
flag to preact watch
, which would enable SW caching while using the HMR server. And preact build
would (hypothetically) continue to output production-ready registration code, since that is the "production" command.
from preact-cli.
totally agreed, with push coming in/ background sync it makes sw far less than optional
from preact-cli.
@developit Also after running preact serve
and coming back npm run start
site will always loads in https://localhost:8080
, unless I use www.localhost:8080
or clear my caches. Is it is due to certificate generated for http2??
from preact-cli.
@lukeed @developit do we have a conclusion of this thing yet?
from preact-cli.
@lukeed Yep. I understood that. Yes I am clearing cache and making it work. Thanks
from preact-cli.
B2T
Download:
https://raw.githubusercontent.com/developit/preact-cli/master/src/resources/cert.pem
and add it to your System trusted certificates.
On MacOs it's simple as click on the file add it to Keychain, right click it "Get Info" and under "Trust" switching "Secure Sockets Layer (SSL)" to "Always trust"
Don't forget to restart your browser.
Alternatively:
Buy a signed certificate or generate your own self signed and replace the preact-cli cert.pem with this one.
from preact-cli.
We've removed the root CA since it opens up a fairly nasty vulnerability that lets anyone who can get access to your connection spoof any SSL certificate. Instead, preact-cli
now uses devcert to generate SSL certificates that are only valid for your machine.
from preact-cli.
Related Issues (20)
- compilingโ ERROR Error: Babel-loader config not found!!! HOT 9
- Pages duplicate when accessing with /index.html HOT 9
- Brotli build - outputs content to same filename HOT 4
- default project template doesn't work with Node v18 HOT 4
- ERROR Error: error:0308010C:digital envelope routines::unsupported HOT 1
- Duplicated content when using /routes when using CLI v4 HOT 5
- Homepage content loaded on all non-prerendered pages HOT 3
- Add Typescript increasses the bundle size HOT 4
- Can't resolve 'preact-cli-entrypoint' HOT 4
- Exported rest param syntax functions create invalid build JS HOT 4
- preact-cli hangs after "โ Done!" HOT 5
- CSS source maps missing in build output HOT 3
- Typescript v5.1.6 compatibility HOT 2
- Route code-splitting breaks lazy loading of images HOT 3
- Use esbuild instead of babel HOT 2
- Fail to build due to `property missing ':'` when inline style HOT 4
- "TypeError: Cannot read properties of undefined (reading 'call')" when trying to route split HOT 7
- OptimizeCssAssetsPlugin causes build to crash in Yarn PnP mode HOT 2
- Config file failure when adding plugins HOT 8
- build gets stuck at "after chunk asset optimization" HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preact-cli.