Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

host is null #1

Open
karellm opened this Issue · 2 comments

3 participants

@karellm

Hi,

I have rack-livereload and guard-livereload installed in a Rails app setup as follow.

I have that setup in my environment/development.:

    Rack::Lock, Rack::LiveReload,
    :min_delay => 500,
    :max_delay => 10000,
    :port => 35729,
    :host => 'mywebsite.local'
  )

I have the following in my views/layouts/application.html.erb:
<%= javascript_include_tag "http://mywebsite.local:35729/assets/lib/livereload.js" %>

I've obviously restarted my server. I get the following console error:
LiveReload cannot connect to null:35729, will retry in 60000 sec.

I have my port 35729 listened by Apache and the js file is accessible.

I've tried to track down the problem without success. It is weird that the host is null. I've noticed that the regex for parsing the host is kinda broken. In my case (Rails), the path to the asset is /assets/lib/livereload.js; it generates a host as mywebsite.local/assets/lib when I would expect mywebsite.local.

In the dist/livereload.js on line 326, the regex is:
/^[^:]+:\/\/(.*)\/z?livereload\.js(?:\?(.*))?$/

when it should probably be:
/^[^:]+:\/\/([^\/]+).*\/z?livereload\.js(?:\?(.*))?$/

Do you have any idea of what is going on?

@zeorin

Hi, I just solved this issue for myself: when livereload.js is not being served from the domain root, but from a subfolder, you need to explicitly set a host, like this:
<%= javascript_include_tag "http://mywebsite.local:35729/assets/lib/livereload.js?host=mywebsite.local" %>

The documentation should be updated to reflect this, as currently it seems to indicate that this is only necessary when one pulls the script from a different domain.

@andreyvit andreyvit closed this in #25
@andreyvit andreyvit reopened this
@andreyvit
Owner

Actually I didn't mean to close it, #25 is only a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.