question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Links in the preview are broken.

See original GitHub issue

First of all, thanks to everyone for the work on version 4, it turned out great.

Issue Summary

When I click on a link within the preview, I get an error message. To get rid of the error message, I have to reload the page. I did not expect to be able to navigate through the page, but there should not be an error message.

grafik

Steps to Reproduce

  1. Install bakerydemo
  2. Start server (./manage.py runserver) and login as admin
  3. Open the preview
  4. Click a link
  • I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no

Technical details

  • Python version: Python 3.10.6
  • Django version: 4.0.7
  • Wagtail version: 4.0
  • Browser version:
  • Firefox 104.0.1 (64-bit)
  • Chrome 105.0.5195.52 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
laymonagecommented, Sep 2, 2022

Hey, thanks for the report!

I’m not sure if this is something we should handle on Wagtail’s side, but the error is because the real page (not-preview) has the X-Frame-Options header set to DENY.

There are some workarounds to this:

  • In your base template, add the following <base> element within the <head> element, before any <link> elements:
    {% if request.in_preview_panel %}
        <base target="_blank">
    {% endif %}
    
    This will make all links in the preview panel open in a new tab. You can also use _parent if you prefer the link to be opened in the same tab.
  • Or, set your X-Frame-Options to SAMEORIGIN. This does not handle external links, so the issue will still show up if the external site doesn’t allow iframes.

I think it’s also possible for Wagtail to modify all links in the iframe to use target="_blank" or disable all links within the iframe, but I don’t think it’s a good thing to do…

0reactions
krzysztofjeziornycommented, Sep 3, 2022

Thanks @laymonage for pointing out the x-frame-options header.

The DENY setting is on in quite popular boilerplate projects for both Nginx and Apache.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Facebook broken link preview - ClickWP
Fix Facebook broken link preview · 1. Visit the Facebook debugger tool – https://developers.facebook.com/tools/debug/ · 2. Paste in the problem link and click...
Read more >
Facebook link preview not working? Little tips to fix it.
1. Go to the Facebook Debugger Tool; · 2. Copy and paste the URL you're having troubles with into the tool and click...
Read more >
How to Fix Your Link Previews on LinkedIn (Post Inspector Tips)
It will only refresh the preview for that particular shared link. Sticking to the Post Inspector, it's your best option and takes three...
Read more >
Broken links: "This is not the page you were looking for..."
... or what has changed, but now all of my links are broken on my website. If I go into Preview Mode and...
Read more >
Twitter link previews broken on iMessage again - 9to5Mac
Twitter link previews are broken in iMessage for the second time this year. The issue prevents iPhones from previewing tweets when shared.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found