Giter Club home page Giter Club logo

Comments (9)

developit avatar developit commented on May 22, 2024 4

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.

lukeed avatar lukeed commented on May 22, 2024 1

@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.

lukeed avatar lukeed commented on May 22, 2024

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.

prateekbh avatar prateekbh commented on May 22, 2024

totally agreed, with push coming in/ background sync it makes sw far less than optional

from preact-cli.

gokulkrishh avatar gokulkrishh commented on May 22, 2024

@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.

prateekbh avatar prateekbh commented on May 22, 2024

@lukeed @developit do we have a conclusion of this thing yet?

from preact-cli.

gokulkrishh avatar gokulkrishh commented on May 22, 2024

@lukeed Yep. I understood that. Yes I am clearing cache and making it work. Thanks

from preact-cli.

derappelt avatar derappelt commented on May 22, 2024

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.

developit avatar developit commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.