We've moved discussions to Discord

lvh.me vs localhost?

Hey,

Context
When testing emails in development using letter_opener, I found out that the default domain for the links was lvh.me, e.g. http://lvh.me:5000/users/password/edit?reset_password_token=....
This seems to be set from config/environments/development.rb:
config.action_mailer.default_url_options = {host: "lvh.me", port: ENV.fetch("PORT", 3000).to_i}

So I tried looking into this lvh.me thing (didn't really know about it), and saw it was especially useful for testing with subdomains. However, when accessing http://lvh.me:3000/, I have some warnings in the devtools related to livereload:
12:23:17.119 Content Security Policy: The page's settings blocked the loading of a resource at ws://lvh.me:35729/livereload ("connect-src"). livereload.js:192:21

It seems that the livereload authorization is set in config/initializers/content_security_policy.rb.
However it is hardcoded with localhost, and I can't find any reference to lvh.me:
  if Rails.env.development?
    srcs = ["http://localhost:3035", "ws://localhost:3035", "ws://localhost:3000", "ws://localhost:5000"]
    srcs += ["http://localhost:35729", "ws://localhost:35729"] if Jumpstart.config.livereload?
    policy.connect_src :self, :https, *srcs
  end
Questions
1. Can I / Should I add something like policy.connect_src :self, :https, "*.lvh.me"?
2. Which domain is it better to use for development, http://localhost:3000/ or http://lvh.me:3000/ ? Am I supposed to search and replace the various Rails configs with one or the other domain depending on which one I use?

Thank you!
Chris Oliver
It's been a long time since I looked at this but I remember there being an issue with wildcards or something so I wasn't able to set that as the default.

Did you try the wildcard?
Notifications
You’re not receiving notifications from this thread.