-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Live reload doesn't respect --baseURL setting #6595
Comments
Can you tell me what real problem you're trying to solve? Note that this is a development server. |
I have a web server with a hugo installation. Nginx on that server is configured to serve the generated pages. To change something, I ssh into the server, write some text and run hugo to re-generate the page. When I want to run The easiest way would probably be to use |
I suggest something ala:
Your setup seems a little too special/complex for us to add complexity to support it. |
As far as I can tell a baseURL with a subdir like I don't think it would add much complexity, basically it's just a |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
hi @bep, To give a hopefully more compelling example of a real problem; One of my clients I am doing contract work for uses hugo internally and currently provides sites for their customers as part of a larger offering. In this particular use case, being able to put the preview behind a path is a requirement to avoid collisions in the namespace of the editor environment's api and the preview instance, as we don't have complete control over the customers DNS settings to place it on a subdomain. While supporting such an editor environment is not really part of this projects concern, given the relatively minor change to support it, I hope you can see some value in reconsidering these changes. |
I think I may have misunderstood you. Are you saying that running with: |
It works in a way which works for local development, but not in the above example case. Regardless of any value passed in |
OK, then I understand. Let's continue the discussion in the reopened PR. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
For the sake of my sanity, is I'm using hugo server --baseURL=https://example.com --port=3000 --appendPort=false Version
And I'm getting errors when the livereload ws tries to connect on port 3000. What's the URL for the PR? |
@ryanburnette It appears it is broken, no matter what you do, port is appended. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes, the current git master version has the same behaviour.
The problem
livereload.js
Hugo always tries to load
livereload.js
from the hardcoded path/livereload.js
, even when there is a--baseURL
parameter that specifies a different root path. So, for example, with--baseURL=https://tejp.de/drafts/
I would have expected the livereload script to be loaded fromhttps://tejp.de/drafts/livereload.js
or simply/drafts/livereload.js
, but not from/livereload.js
which lies "outside" of the baseURL.Other page resources respect the specified baseURL, so I would have expected the support scripts for livereload to do the same.
What's wrong with that?
So why is that a problem? My use case for
--baseURL
including a path was to access the hugo server through a proxy as a subdirectory on my webserver, accessible ashttps://tejp.de/drafts/
.So
https://tejp.de/drafts/
and everything below gets proxied tohttp://localhost:1313/
. I add some authentication and now I can view my draft posts conveniently at that URL. It works nicely, only live reload doesn't work because it uses a different path.I imagine such a proxy to be the main use case for
--baseURL
.livereload websocket
If I reconfigure things so livereload.js gets loaded successfully, it tries to open a websocket connection to
/livereload
, again without using the--baseURL
setting. This websocket should also be located below baseURL and not "leak" into the toplevel directory.This can easily be accomplished by passing an additional
path=...
URL parameter to livereload.js.Fixing it
It is quite possible that I misunderstand how live reload is supposed to work and am going in the wrong direction, but not I have a proof of concept patch that implements these changes. It needs some polishing but should work out without major problems.
The text was updated successfully, but these errors were encountered: