Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dynamic script returned when hostname and ember server are on different ports. Setting options.liveReloadPort breaks the loading of livereload.js script #56

Closed
sumeetattree opened this issue Oct 10, 2018 · 3 comments

Comments

@sumeetattree
Copy link

Background:
Ember server running on 192.168.0.244:4200
Rails server that serves the built app is running on 192.168.0.244:3000
We are following the ember-cli-deploy lightning method which pushes the built html file to redis store which is then served via rails.

There are two things that are going on here:

  1. if you set liveReloadPort: 4200, nothing happens. livereload.js is still served from 192.168.0.244:3000. I suspect it is due to these lines here
    if (options.liveReloadPort !== options.port) {
      liveReloadPort = options.liveReloadPort
    }

If they are same, which they are in this case, liveReloadPort never gets set. Which would be fine if the script was actually loaded from 4200 but it looks at the location.port which is 3000

  1. If you set liveReloadPort: 4700 (some arbitrary number), the generated dynamic script breaks on this line with this error:
    var prefixURL = '(location.protocol || 'http:') + '//' + host + ':' + 4700'; // Syntax Error

Unrelated; could I also interest you in exposing liveReloadBaseUrl, liveReloadPort, and liveReloadHost via ember-cli-build config? Currently we are serving these files from a different port (4200) than the server that's serving the files (3000). Something like this would be ideal:

    // ember-cli-build.js
    let app = new EmberApp(defaults, {
      emberCLILiveReload: {
        liveReloadBaseUrl: process.env.ASSET_HOST,
        liveReloadPort: 4700
      },
    });

These options can then be merged like so on this line

  serverMiddleware: function(config) {
    var self = this;
    var app = config.app;
    var options = config.options;
    // this will become
    var options = Object.assign(config.options, this.app.options.emberCLILiveReload)
@Paxxinet
Copy link

Paxxinet commented Oct 15, 2018

  1. If you set liveReloadPort: 4700 (some arbitrary number), the generated dynamic script breaks on this line with this error:
    var prefixURL = '(location.protocol || 'http:') + '//' + host + ':' + 4700'; // Syntax Error

Even when no changes are made to a brand new project (ember version 2.18, ember-cli-inject-live-reload version 2.0.0), the below error is shown and when downgraded to ember-cli-inject-live-reload version 1.8.2 - no error is shown and all is good.

error with 2_0_0 version 1
error with 2_0_0 version 2

buschtoens added a commit to buschtoens/ember-cli-inject-live-reload that referenced this issue Oct 15, 2018
@rwjblue
Copy link
Member

rwjblue commented Oct 15, 2018

Thank you for such a detailed issue report!

@rwjblue
Copy link
Member

rwjblue commented Oct 15, 2018

Also requires #66 to work with [email protected]...

rwjblue pushed a commit that referenced this issue Oct 15, 2018
Fixes #56.

(cherry picked from commit 7f5ffad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants