Code Monkey home page Code Monkey logo

Comments (3)

wbobeirne avatar wbobeirne commented on July 17, 2024 5

IMO would love to see the effort to get a dev env setup reduced. I think wrapping that in a conditional for running in development would be nice, e.g.

if (process.env.NODE_ENV === 'development' && !process.env.VAPID_MAILTO) {
  console.info('VAPID_* env vars not set in development, skipping webPush setup')
} else {
  webPush.setVapidDetails(
    process.env.VAPID_MAILTO,
    process.env.NEXT_PUBLIC_VAPID_PUBKEY,
    process.env.VAPID_PRIVKEY
  )
}

Alternatively, move the setVapidDetails call into one (or many) of the async functions so that it just throws on the first time you attempt to do anything with push, rather than during initial render.

from stacker.news.

SatsAllDay avatar SatsAllDay commented on July 17, 2024 1

IMO would love to see the effort to get a dev env setup reduced. I think wrapping that in a conditional for running in development would be nice, e.g.

if (process.env.NODE_ENV === 'development' && !process.env.VAPID_MAILTO) {
  console.info('VAPID_* env vars not set in development, skipping webPush setup')
} else {
  webPush.setVapidDetails(
    process.env.VAPID_MAILTO,
    process.env.NEXT_PUBLIC_VAPID_PUBKEY,
    process.env.VAPID_PRIVKEY
  )
}

Alternatively, move the setVapidDetails call into one (or many) of the async functions so that it just throws on the first time you attempt to do anything with push, rather than during initial render.

Just a +1 here, I used the above quoted code snippet to enable local development and it got me past this issue. Thank you for the workaround!

from stacker.news.

ekzyis avatar ekzyis commented on July 17, 2024

Ah, thanks for the issue and you are right! It doesn't work without setting up these environment variables and we should update our documentation.

For the VAPID keys, you can run npx web-push generate-vapid-keys. VAPID_MAILTO should just be a mail prefixed with mailto:. So mailto:[email protected] should work.

There may be a similar issue for the imgproxy env but these don't prevent starting the server. However, It may break the frontend when visiting some posts. For IMGPROXY_KEY and IMGPROXY_SALT you can run openssl rand -hex 64.

Would you mind creating a PR to document this? Else I can do this soon.

from stacker.news.

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.