- Notifications
You must be signed in to change notification settings - Fork326
Make Hugo's LiveReload work on RStudio Server#738
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…udio.cloud/p/hex, and use it as the baseURL, so that both livereload.js can be loaded (gohugoio/hugo#6698), and absolute URLs will work (this needes to be fixed because not all Hugo templates use the `relURL` function---some do generate absolute URLs, which will fail on RStudio server)
…RLs (ah, this is too complicated to explain...)
…t get around---RStudio Server seems to intefere with loading Hugo's livereload.js via the proxied port (the script can be read directly from the port, though)
@yihui I don't know fully the context here but just a reminder aboutrstudio/rstudio#8096 that we added in#496 Slightly related, but maybe another issue as the RStudio IDE could have been using specific treatment, probably meant for Quarto which uses livereload.js I think. Anyway, you're onto it! |
Yes, I do rememberrstudio/rstudio#8096 well. That helped to some extent, and we have been "cheating" in the sense that we are refreshing the RStudio viewer by ourselves, instead of letting Hugo do it. This has a few limitations:
Originally Hugo had a bug (gohugoio/hugo#6698) so there was no hope that its |
Uh oh!
There was an error while loading.Please reload this page.
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.jssuccessfully 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.jswithout the.jsextension, we get a status code400(bad request) instead of the usual404:https://xxxxxx.app.rstudio.cloud/p/xxxxxx/livereloadIt seems that RStudio Server has a special routing mechanism for the filename
livereload.jsno 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.