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

LiveReload doesn't work in GitHub Codespace #9936

Closed
markgoho opened this issue May 26, 2022 · 6 comments · Fixed by #9977
Closed

LiveReload doesn't work in GitHub Codespace #9936

markgoho opened this issue May 26, 2022 · 6 comments · Fixed by #9977

Comments

@markgoho
Copy link

markgoho commented May 26, 2022

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.99.1-d524067382e60ce2a2248c3133a1b3af206b6ef1+extended linux/amd64 BuildDate=2022-05-18T11:18:14Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

General Problem description

LiveReload doesn't seem to work in GitHub Codespaces. This seems to be due to the port being appended to the url even when --appendPort=false is passed to the cli

image

@bep
Copy link
Member

bep commented May 27, 2022

Hmm... I'm pretty sure I have been using in similar settings before ... But "someone" may have broken it.

@bep bep self-assigned this May 27, 2022
@bep bep added this to the v0.100.0 milestone May 27, 2022
@bep
Copy link
Member

bep commented May 27, 2022

Never mind, I see it now (at least what the plan was).

  • appendPort=false is for baseURL only
  • Set liveReloadPort=443 (or something) if you're doing some proxy setup.

Let me know if that works for you.

@bep bep added CantReproduce and removed Bug labels May 27, 2022
@markgoho
Copy link
Author

markgoho commented May 27, 2022

that doesn't work either, here is the repository I'm using: https://github.com/ideacrew/sbm-docs

here are the options I've tried and the errors that I'm getting in the console

hugo server => livereload.js?mindelay=10&v=2&port=1313&path=livereload:1 WebSocket connection to 'wss://markgoho-ideacrew-sbm-docs-779rj57j3pv95-1313.githubpreview.dev:1313/livereload' failed:

hugo server --liveReloadPort 443 => livereload.js?mindelay=10&v=2&port=443&path=livereload:1 WebSocket connection to 'wss://markgoho-ideacrew-sbm-docs-779rj57j3pv95-1313.githubpreview.dev/livereload' failed:

hugo server --liveReloadPort 80 => livereload.js?mindelay=10&v=2&port=80&path=livereload:1 WebSocket connection to 'wss://markgoho-ideacrew-sbm-docs-779rj57j3pv95-1313.githubpreview.dev:80/livereload' failed:

@bep
Copy link
Member

bep commented May 27, 2022

OK, I don't understand the GitHub Codespaces good enough to tell what/why.

@markgoho
Copy link
Author

Yeah, I guess there's some similarities with a technology called GitPod where folks have found a similar issue but have resolved it with --bind=0.0.0.0

It's entirely possible that:

  1. there's some combination of server flags that might work, no code change required anywhere
  2. however livereload works in Hugo, it won't work in codespaces and a change might be required either in Hugo, codespaces, or livereload (😬)

In either case, I don't think enough people use codespaces (yet!) for this to matter much

thanks for the time you've already put in -- maybe someone else will find this issue and come up with solution

@bep bep modified the milestones: v0.100.0, v0.101.0 May 31, 2022
satotake added a commit to satotake/hugo that referenced this issue Jun 5, 2022
Codespace has 2 types of usage

1. in browser
2. vscode on local computer

As long as you select 2 (on local), Hugo handles livereload expectedly.
But if you use it in browser, Hugo does not reload on file change, as gohugoio#9936 said.

This issue happens because `CheckOrigin` always fails.
Remote server could rewrite request host name.
Fix this by respecting `X-Forwarded-Host` header during origin checking

After merging this, you can preview changes lively with codespaece in browser.

```sh
hugo server --liveReloadPort 443
```

Close gohugoio#9936
@bep bep closed this as completed in #9977 Jun 5, 2022
bep pushed a commit that referenced this issue Jun 5, 2022
Codespace has 2 types of usage

1. in browser
2. vscode on local computer

As long as you select 2 (on local), Hugo handles livereload expectedly.
But if you use it in browser, Hugo does not reload on file change, as #9936 said.

This issue happens because `CheckOrigin` always fails.
Remote server could rewrite request host name.
Fix this by respecting `X-Forwarded-Host` header during origin checking

After merging this, you can preview changes lively with codespaece in browser.

```sh
hugo server --liveReloadPort 443
```

Close #9936
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants