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

iframe always loads from localhost (binary only, without docker) #321

Closed
smurfpandey opened this issue May 9, 2019 · 6 comments
Closed
Milestone

Comments

@smurfpandey
Copy link

I am trying to install remark on my server without docker. I can load the /web page but, iframe is trying to load from http://127.0.0.1:8080. I have installed remark on different domain though.

My startup command: /var/www/remark42/remark42.linux-amd64 server --secret=qwe456@789 --url=http://comment.local.server/ --auth.anon --site=blog-local

@smurfpandey smurfpandey changed the title comment iframe always loads from localhost iframe always loads from localhost May 9, 2019
@umputun
Copy link
Owner

umputun commented May 9, 2019

The issue is real, but non-dockerized version only. Binary doesn't do this step and artifact's build enforcing 127.0.0.1:8080

I'm not sure (yet) how to fix this. @Reeywhaar probably nothing can be done on your side to mitigate it?

@smurfpandey the only short-term workaround i can think of - change Dockerfile.artifacts with your domain and build it from the source., i.e. make bin. Or, alternatively, switch to dockerized version.

@umputun umputun changed the title iframe always loads from localhost iframe always loads from localhost (binary only, without docker) May 9, 2019
@Reeywhaar
Copy link
Collaborator

Reeywhaar commented May 9, 2019

One solution I see is to explicitly provide remark host in remark_config, and move all thing regarding determining host from bundle time to runtime.

Also, as we changing client setup, we can provide different startup script which will solve another problem: bundle size. Right now embed.js, last-comment.js, counter.js all have vendor deps bundled with each one of them. We can make them use one single shared vendor.js.

So, resulting script would be something:

<script>
  var remark_config = {
    host: 'REMARK_HOST', // host of remark server, e.g. "https://demo.remark42.com"
    site_id: 'YOUR_SITE_ID',
    components: ['comments', 'last_comments', 'counter'], // optional param; which components to load. default to ['comments']
    url: 'PAGE_URL', // optional param; if it isn't defined window.location.href will be used
    max_shown_comments: 10, // optional param; if it isn't defined default value (15) will be used
    theme: 'dark', // optional param; if it isn't defined default value ('light') will be used
    page_title: 'Moving to Remark42' // optional param; if it isn't defined `document.title` will be used
  };

  (function(c) {
    for(var i = 0; i < c.length; i++){
      var d = document, s = d.createElement('script');
      s.src = remark_config.host + '/web/' +c[i] +'.js';
      (d.head || d.body).appendChild(s);
    }
  })(['vendor'].concat(remark_config.components || ['comments']));
</script>

@umputun
Copy link
Owner

umputun commented May 9, 2019

Handling all of this on client side sound like a good idea to me. This change will make all the setup less magical, i like it

@smurfpandey
Copy link
Author

Thank you for the work-around suggestion. I will try building the binary myself and see how it goes.

@umputun
Copy link
Owner

umputun commented May 14, 2019

i have released v1.3.2 with the support of configurable host

@smurfpandey let me know if it addressed your issues

@smurfpandey
Copy link
Author

It works. Thank you for the quick fix. :)

@paskal paskal added this to the v1.3 milestone Jan 15, 2023
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

4 participants