Ghost/apps/comments-ui
Kevin Ansfield ef143978e7
🎨 Reduced requests and 403 responses for comments auth check (#19840)
closes https://linear.app/tryghost/issue/ENG-721
ref https://linear.app/tryghost/issue/ENG-708

Comments-UI loads `/ghost/admin-frame/` in an iframe to check if a Staff User is authenticated in order to  show moderation options. That iframe request loads a HTML page which in turn contains a script that fires off an API request that attempts to fetch the logged-in user details, resulting in a 403 "error" showing up when not authenticated. In the vast majority of cases there will be no staff user authenticated so lots of extra requests and "errors" are seen unnecessarily.

- adjusted the `/ghost/auth-frame/` endpoint to check if the request contains an Admin session cookie
  - if it does, continue as before with rendering the HTML page so the script is loaded
  - if it doesn't, return an empty 204 response avoiding the script request and subsequent 403-generating API request
- eliminates the 403 error being generated for all typical visitor traffic, the error should only be seen when an Admin was previously logged in but their cookie is no longer valid (either from logging out, or going past the 6month validity period)
2024-03-12 12:27:18 +00:00
..
src Added lazy-loading of admin auth in Comments UI (#19799) 2024-03-05 15:57:20 +00:00
test 🎨 Reduced requests and 403 responses for comments auth check (#19840) 2024-03-12 12:27:18 +00:00
.env Added custom build setup 2022-07-04 15:15:01 +02:00
.eslintrc.js Extended translations beta to comments (#17801) 2023-08-24 10:33:03 +02:00
.yarnrc Prevented git tags from being created for apps 2023-07-10 13:09:28 +02:00
LICENSE Migrated from Webpack to Vite and updated dependencies 2023-06-21 15:28:01 +02:00
package.json Released comments-ui 0.16.0 (#19800) 2024-03-05 16:20:19 +00:00
playwright.config.ts Temporarily increased timeout for Comments-UI web server init 2023-09-15 10:48:08 +02:00
postcss.config.cjs Migrated Comments-UI to TypeScript (#17129) 2023-06-27 14:51:37 +02:00
README.md Configured yarn dev to allow starting Comments-UI 2023-06-22 10:23:05 +02:00
tailwind.config.js Removed the duplicate sm config 2022-11-11 15:25:57 +00:00
tsconfig.json Converted Comments-UI App to TypeScript and React hooks (#17760) 2023-08-18 13:30:59 +00:00
tsconfig.node.json Migrated Comments-UI to TypeScript (#17129) 2023-06-27 14:51:37 +02:00
vite.config.ts Hidden "info" Vite output unless in CI 2023-11-15 10:11:22 +01:00

Comments UI

Comments widget that is embedded at the bottom of posts in Ghost.

Development

Pre-requisites

  • Run yarn in Ghost monorepo root

Running via Ghost yarn dev in root folder

You can automatically start the comments dev server when developing Ghost by running Ghost (in root folder) via yarn dev --all or yarn dev --comments. This will host the comments JavaScript files, and makes sure that Ghost uses these locally hosted assets instead of the ones from the CDN.

Copyright & License

Copyright (c) 2013-2023 Ghost Foundation - Released under the MIT license.