使用安全模式排查主题和插件问题

:bookmark: 本指南介绍如何使用 Discourse 的安全模式来排查主题和插件相关的问题。

:person_raising_hand: 所需用户级别:所有用户

Discourse 提供“JavaScript 安全模式”,允许任何用户隔离由插件、主题或主题组件引起的 JavaScript 问题的根本原因。此功能对于排查您 Discourse 站点上的问题特别有用。

访问安全模式

要访问安全模式,请按照以下步骤操作:

  1. 打开新的浏览器标签页。

  2. 在地址栏中输入以下 URL,并将 [your-site-name](http://discourse.example.com) 替换为您实际的 Discourse 站点域名:

    http://discourse.example.com/safe-mode
    

    例如,Discourse 演示站点的“安全模式”URL 为:
    https://try.discourse.org/safe-mode

  3. 点击“进入安全模式”按钮:

安全模式选项

进入安全模式时,您可以选择以下选项:

  • 禁用主题和主题组件
  • 禁用非官方的客户端插件自定义
  • 禁用所有客户端插件自定义
  • 使 JavaScript 弃用项引发错误

默认情况下,前三个选项处于选中状态。“弃用错误”选项默认未勾选,主要用于插件和主题开发者测试与即将发布的 Discourse 更新的兼容性。您可以多次以不同的组合进入安全模式,以隔离导致您站点出现问题的特定组件。

使用安全模式

  1. 在安全模式页面上选择所需的选项。
  2. 点击“进入安全模式”以应用您的选择。
  3. 您将看到一个横幅,提示安全模式已启用。
  4. 浏览您的站点,检查在禁用所选组件后问题是否仍然存在。

退出安全模式

要退出安全模式,只需关闭您的浏览器标签页即可。

重要提示

在分享您站点的安全模式链接时,请注意,该链接需要在新标签页中打开,或直接添加到地址栏中;否则可能无法正常工作。

:warning: 安全模式目前仅禁用插件的 JavaScript 部分。要禁用插件的服务端部分,您必须通过注释掉插件来重新构建容器。

故障排查

如果您无法加载初始的安全模式选择页面,请尝试访问以下 URL,该 URL 将跳过该页面并直接加载安全模式:

https://discourse.example.com/?safe_mode=no_themes,no_plugins

例如:https://try.discourse.org/?safe_mode=no_themes,no_plugins

可用的 safe_mode 查询参数值为:no_themesno_unofficial_pluginsno_pluginsdeprecation_errors。这些值可以用逗号组合使用。

73 个赞
Admin Plugin page is blank - Error: There is no route named adminPlugins.index
502 and then empty forum after `./launcher rebuild app`
Upgraded last night and login button no longer works
Content of messages not showing up
"About" pages crashing our Discourse
Topic Preview Broken (due to Google PageSpeed Module)
Uncaught Errors
Manually Clear DistributedCache
Browser too old message when "compatibility mode" is forced in IE 11
Admin Plugin page is blank - Error: There is no route named adminPlugins.index
My site just broke after restarting server
After Recent Upgrade to 1.08? beta - No forum shows
Blank topics after import?
Problems clicking topic links in IE11
Website looks different on different browsers
How to disable a component without access to site?
Cannot create new topics (already disabled plugins)
How to increase site speed
Disable plugins without restarting?
A "safe mode" to easily disable all third party plugins
Beginner's guide to using Discourse Themes
Global notice doesn’t show
Incorrect initial order when user sorts topic list
Unable to expand profile
Disable plugin without downtime?
Mobile Header expanding after tapping hamburger menu
Discourse 2.3.0.beta10 Release Notes
Lightbox not showing up on uploaded images after update
Vimeo onebox not working
Pasting tables from spreadsheets no longer working after 2.3 upgrade
Contains_dtoc in Grey Amber theme header
Site fails to load with js errors
No content displayed on front category page after upgrade
Notifications are acting strange
Occasional page loads with no post content due to plugins
Discourse 2.5.0.beta2 Release Notes
LDAP Setup for Discourse
Unable to add/edit tags
Category unlike any other category
Unable to save wiki update
Infinite scroll not working in "Latest" on Mobile
Disappearing posts in 2.1.0.beta2
Post content not showing up
In-post links to topics - no longer update to the initial posts title
Issue with menu, admin
Excerpts truncating at 50 characters
How to change default Discourse theme via CLI?
Mentions reported wrongly as replies in notifications list
Bad JS customizations - how to fix in the backend?
Send Invites button should not be visible if local logins are disabled
Topic-footer buttons are disappearing
Blank pages, 500 errors and no logs
[2.1.0b6] New topic button is moving behind burger on click
Google, Twitter and Facebook Logins not working due to ad blocker
Can't See Posts When Logged Out
After latest admin/upgrade my Admin dashboard won't load
My install was broken because I upgraded but did not upgrade plugins
Bulk edit icon not showing?
Quoting is not working anymore
Some user see a blank page when opening a topic
Admin Trouble Creating a Category
Browser Back Button issue
Topic mismatch troubleshooting
Edit icon not activating after edits
I don't see the staff wrench on posts
Forum does not work for users on iOS
Category autocomplete stopped working on our site?
UI not loading after git pull update
Gui for querying category of solved or unsolved topics
Image displayed incorrectly on Mobile due to theme settings
Preview of post not loading because force https was not set
Reordering Categories Produces Error 422
Limit on Number of Child Categories?
Issue in user summary
Lightbox for images comes by default?
Having an issue with images' width getting cut off on desktop
Issue with the page title in Arabic?
Latest update broke my forum
Registration modal/popup not showing up for private instance
Iframes Not Working
Discourse unresponsive in Chrome
Topics tagged with `info` have strange appearance
Logins redirects to missing notifications page
Discourse broken after upgrade
Topic Will Close A Few Seconds After The Last Reply
Issues with index page infinite scrolling?
How might we better structure #howto?
Hashtags with numbers in parentheses appearing everywhere on Discourse site
After updating to 2.8.0.beta8, nothing shows as "read" anymore
Breaking Mobile view check after Discourse update to 2.5.0.beta7
Dashboard empty since upgradeto 2.5.0
Can’t create new category
Login form missing entirely from Discourse instance
Blank website after update
Content won't load after update
Category link failed after updating today
Error 500 on category page and homepage after upgrade to 2.6
Mouse click is not working in my forum after recent update
Screen black out bug on modal
Social share components do not appear
Admin panel does not work
Totally blank upgrades page
Accidentally overwrote application.hbs || Enter safe mode
Latest beta update (2.7.0b7) gone wrong
Some topic category boxes are missing
Need help reverting forums. I made a mistake
Pups::ExecError: su postgres -c 'psql discourse -c "alter schema public owner to discourse;"' failed with return
Can not access Discourse - blank page
Site broken after update
The "Save Changes" button is very low on my user preferences interface page
Phantom signups (two users with the same account after migration)
Homepage (sub)category display - lots of whitespace
Category Image Formatting
Update problem help pls
Bug on topic interface after an update || Resolved
Scroll jank when scrolling up
504 Gateway Timeout for some reports
Trust level 1 users cannot Invite
Error: Something went wrong - "Error while processing route: discovery.categories"
Loading groups gives internal server error
UI not rendering in Chrome/Firefox due to CloudFlare rocket loader
Private Message Can't Be Reached with private messaging disabled
How many category moderators are shown on about page?
What on earth is causing this?
While loading a new component on the site, the site is down
IP Lookup UI is broken
My forum is stuck on the loading screen
Safe-mode failed with a plugin
After upgrading to discourse 3.. can only access to admin using safe-mode
BBCode `url` tags break if wrapped text ends in URL with component after host
Fedoras Discourse instance made some troubles. Could the support please give some feedback
Minimizing Maintenance on Theme Customizations
Hide topic timeline
Forum stuck on the loading home screen
MacOs users on old version can´t read posts
Easy Responsive Footer Plug-in bug issues
Inline formatting used when "preformatted text" formatting applied to multi-line selection
Moving the server
Entire site is a blank page after upgrade
Collapse Button Not Working on Profile Page (Mobile)
Discourse forum wont load any pages whatsoever
`white-space` CSS property of clipboard data not respected when pasting in rich text editor
Discourse broken after moving servers
Dragging highlighted texts causes Chrome freeze
Client-side vs. server-side?
Client-side vs. server-side?
While loading a new component on the site, the site is down
Can't get Ruby to update so ./launcher rebuild app keeps failing
Base_path not being substituted in some cases
Edit CSS/HTML of custom theme not appearing
Finding Discourse RSS feeds
500 Error when posting, moment.tz runtime error
Some DMs are not visible
Air Theme Latest Update - Crash
Dashboard New Posts statistics broken
Made some changes I cannot revert
Floating search box cannot be closed when device goes from horizontal to vertical
I'm getting errors when I switch categories too quickly
Inline “preformatted text” formatting used when multi-line selection doesn't contain hard break
Coincidental Markdown in formatted content pasted to rich text editor rendered on publish
Category settings broken
Spurious notification when navigating away from review queue after adding note
Links produced by the Composer link modal break when they contain a ' (%27)
TypeError when submitting a flag with custom content (require_message flags)
OpenClaw plugin for Discourse integration
Case study of an amateur plugin author
500 error on category view mobile due to knowledge base plugin
A topic doesn't open with recent upgrade due to a plugin
Only loading HEAD after upgrading docker, due to Babble plugin
Category Icons
Server errors in 2.5.0.beta3
Weird Formatting Bug in old Microsoft Edge
Topic replies are not displaying in chronological order?
My Discourse site is not loading due to misconfigured CSP
Missing scroll bar slider, in Finnish Localization
Category link failed after updating today
Discourse and Uncaught ReferenceError: ClipboardJS is not defined
The order of characters when typing in the floating search widget is reversed
Using Cloudflare for HTTPS, empty preview pane in edit page
Writing an effective bug report
Avatar settings not visible with SSO
Emoticon button not working anymore (because of babble plugin)
Stable broken due to discourse-spoiler-alert
How to disable a plugin when admin plugin page is not loading
New topic and reply not working
Front page of discourse missing content
Messaging drop down menu not working
The composer needs to be more friendly to iPad Mini

对我来说,这些链接只有在新标签页或窗口中打开时才有效。第一个链接会导向 oops 页面,第二个链接会导向主页。但安全模式横幅没有出现。当你将链接发送给用户让他们尝试安全模式时,第二个链接可能会导致问题。如果他们只是点击链接,他们仍然会在没有安全模式的情况下使用该网站。

也许应该将此信息添加到 #how-to。

4 个赞

抓得好——这两个链接都坏了。第一个需要一个 ?,第二个需要一个逗号而不是 %2C

2 个赞

在哪里需要一个“?”?
您能分享一个链接作为示例吗?

1 个赞

哦,抱歉,看来我第一个说错了:内部导航失败了,但新窗口可以正常工作。
Discourse Meta

我第二个也说错了!Discourse Meta - Discourse 官方支持论坛 不能作为同页导航。

我的错:有些东西坏了,但不是 URL。

1 个赞

我想这是因为它试图就地打开它们。与其争论,我已将其替换为 try.discourse.org:slight_smile:

2 个赞

我认为管理员应该知道分享这些链接很容易出问题。

例如,我在 meta 上报告了一个问题。你可能会问:“你能试试 https://meta.discourse.org/safe-mode 吗?”然后我会告诉你链接不起作用。
或者更糟糕的是:你想指定我只禁用主题,所以你让我试试 https://meta.discourse.org/?safe_mode=no_themes。我的问题仍然存在。你怎么确定我真的使用了安全模式?作为一个用户,我认为它起作用了,因为当我点击链接时发生了一些事情。

在我在这里发帖后,你就知道了。但其他管理员怎么知道他们必须注意这可能是一个问题?

3 个赞

鉴于此安全主页会替换所有内容的性质,我想知道是否应破例在新标签页中打开此链接。

2 个赞

我添加了一个注释,还有一个“成功”的截图。看起来怎么样?

4 个赞

3 篇帖子已拆分为新主题:安全模式是否应默认关闭非员工用户?