about summary refs log tree commit diff
path: root/config/initializers/vapid.rb
blob: 74e07377c69b2f91432391d2e6b032f0b3b48aaa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

Rails.application.configure do

  # You can generate the keys using the following command (first is the private key, second is the public one)
  # You should only generate this once per instance. If you later decide to change it, all push subscription will
  # be invalidated, requiring the users to access the website again to resubscribe.
  #
  # ruby -e "require 'webpush'; vapid_key = Webpush.generate_key; puts vapid_key.private_key; puts vapid_key.public_key;"
  #
  # For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html

  if Rails.env.production?
    config.x.vapid_private_key = ENV['VAPID_PRIVATE_KEY']
    config.x.vapid_public_key = ENV['VAPID_PUBLIC_KEY']
  end
end