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: Use X-Forwarded-Host for Codespace livereload #9977

Merged
merged 1 commit into from
Jun 5, 2022

Conversation

satotake
Copy link
Contributor

@satotake satotake commented 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.

hugo server --liveReloadPort 443

Close #9936

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
@satotake satotake changed the title livereload: Use X-Forwarded-Host for Codespace livereload: Use X-Forwarded-Host for Codespace livereload Jun 5, 2022
@bep bep merged commit 8e2fd55 into gohugoio:master Jun 5, 2022
@markgoho
Copy link

markgoho commented Jun 5, 2022

thank you @satotake -- totally amazed by the quickness with which you figured out what was happening and how to fix it

UPDATE: this works flawlessly!

@github-actions
Copy link

This pull request 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 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LiveReload doesn't work in GitHub Codespace
3 participants