Unknown content API key Error / View site 500 Error

Hi all,

I was getting some odd behavior, essentially getting a 500 error whenever I clicked on view site in the admin panel. The pages still worked but within the frame where the site should be it gave me the ghost tumbleweed 500 error screen.

In the process of debugging that I

  • double-checked my site URL was pointing to https rather than http
  • reran ghost setup nginx ssl
  • reran ghost setup ssl
  • reran ghost doctor for good measure
  • restarted the site

After that the issue seemed to resolve, but I decided to check behind the scenes and so stopped the site and re ran it using ghost run so I could see the output for debugging. I noticed I’m getting the following error whenever I click “view site”.

[2020-06-19 09:47:48] ERROR “GET /ghost/api/v2/content/posts/?key=852e3ba1272c5e8a20c8c7fbbb&limit=all&fields=id,title,url,updated_at,visibility&order=updated_at%20desc&formats=plaintext” 401 5ms

Unknown Content API Key

Error ID:
ef691190-b211-11ea-ba2e-b365a59f8bbf

Error Code:
UNKNOWN_CONTENT_API_KEY


UnauthorizedError: Unknown Content API Key
at new UnauthorizedError (/var/www/ghost/versions/3.20.0/node_modules/ghost-ignition/lib/errors/index.js:120:23)
at Child. (/var/www/ghost/versions/3.20.0/core/server/services/auth/api-key/content.js:22:25)
at Child.tryCatcher (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/var/www/ghost/versions/3.20.0/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)

I’m not sure what is going on here, is it an issue, did it cause my other 500 error problem?
Info
URL: https://www.jallenrobertson.com
Ghost version: 3.20.0
Ghost CLI: 1.14.1
Node: v12.18.0
Ghost was installed using the Digital Ocean 1-click app

Reproduce: Go to admin panel, click on the view site button to load the site in the frame -observe terminal throw the error.

The 401 error is viewable when visiting https://www.jallenrobertson.com/

Looks like it’s maybe coming from code injection:

image

Not sure it’s causing the 500, but makes sense to squash this first and see.

Ah! Thanks @Hannah. It was the API key for the search function in my theme. I’d moved the blog from a local implementation to the ghost droplet and hadn’t generated a new API key for it. I generated a new key and replaced it in my theme config and now we’re all good!