host is null #1

Open
karellm opened this Issue Mar 28, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@karellm

karellm commented Mar 28, 2012

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

This comment has been minimized.

Show comment Hide comment
@zeorin

zeorin Sep 25, 2012

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.

zeorin commented Sep 25, 2012

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

This comment has been minimized.

Show comment Hide comment
@andreyvit

andreyvit Jan 19, 2015

Member

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

Member

andreyvit commented Jan 19, 2015

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