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

Navigating away from a blog post attempts to get the blog's images from the new page #2184

Closed
michaelkedar opened this issue May 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working frontend Frontend Infrastructure

Comments

@michaelkedar
Copy link
Member

Describe the bug
On the website, if you are view a blog post with images and navigate to another page, the browser will attempt to get the images from the blog post relative to the page you've just navigated to, which will 404.

To Reproduce
Steps to reproduce the behaviour:
Monitoring the browsers network requests:

  1. Go to a blog post that has images (e.g. "Announcing Guided Remediation in OSV-Scanner")
  2. Click on a link to another page on the osv.dev site (e.g. Click "Blog" in the navbar)
  3. Observe 404-ed requests made to get images from the new page.

Expected behaviour
The browser should not be trying to fetch blog images when leaving the blog's page.

Screenshots
image

Additional context
Chrome's network browser is telling me the initiator is from @hotwired/turbo, which seems to be interacting with how images are relatively loaded from the hugo-generated blog pages.

@michaelkedar michaelkedar added bug Something isn't working frontend Frontend Infrastructure labels May 9, 2024
@ZhangChen199102 ZhangChen199102 self-assigned this May 14, 2024
michaelkedar pushed a commit that referenced this issue May 22, 2024
Issue: #2184

Turbo always tries to cache the page after a link, but after navigate to
a new page, it can't get the images of the blogs cause they use relative
path, e.g.

https://github.com/google/osv.dev/blob/2e1117e5c9360f755d46165eaf2f2bf6b576d09f/gcp/appengine/blog/content/posts/announcing-guided-remediation-in-osv-scanner/index.md?plain=1#L36

This PR disables the cache feature of Turbo Drive which is a quick
solution, but this will reduce the performance when navigate back to the
blog (content won't be stored and it will load a fresh page).

Another solution is improving the images path for each blog, for example
use
`/static/blog/posts/announcing-guided-remediation-in-osv-scanner/gr_main.png`
instead of `gr_main.png`. But by going this way, we need to keep in mind
to use absolute path when adding a new blog.

Please let me know your thought, or any other solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Frontend Infrastructure
Projects
None yet
Development

No branches or pull requests

2 participants