Make Hugo's LiveReload work on RStudio Server #738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately this doesn't work because I ran into an RStudio Server problem that I can't work around. The problem can be reproduced in the following steps. First create a new site and serve it:
The default port is 4321. We can fetch
livereload.js
successfully from Hugo server via this port:However, it can no longer be correctly loaded if we try to load it via the translated URL (I substituted random strings with
xxxxxx
):It doesn't work either if we paste the URL in the web browser's address bar. By comparison, all other assets work well, e.g.,
https://xxxxxx.app.rstudio.cloud/p/xxxxxx/css/main.css
. Also note that if we try to accesslivereload.js
without the.js
extension, we get a status code400
(bad request) instead of the usual404
:https://xxxxxx.app.rstudio.cloud/p/xxxxxx/livereload
It seems that RStudio Server has a special routing mechanism for the filename
livereload.js
no matter if this file is served by which server (in this case, Hugo). This interference prevents Hugo's LiveReload from working. I wonder if this is a bug of RStudio Server.