GHOST API - Development Environment Issues

I run Ghost on a sub-domain. My main site uses Ruby Rails. I use Ghost API to allow me to display recents/featured posts on the homepage.

My production code works fine, the integration works as expected until it comes times to testing locally with my .env.development config.

  • No matter what I do, I can’t display data from my ghost instance on the dev site.
  • I do not have any firewalls or reasons the data can’t be accessed
  • Using a simple curl statement works fine. All data is visible.
  • The same GHOST_SECRET and GHOST_URL work fine with curl.
  • I have tried adding console debugging, but nothing is flagged.

What am I missing here?

Any help would be greatly appreciated.

Hi! I think we need some more info to help.

I imagine you’re calling the Ghost API from the Rails app or how are you calling the data? What does the API call return?

My code uses the GHOST Api to call standard information for recent posts. I use it to list recent posts on my Rails homepage. So it calls things like: title, exceprt, image, url.

However, that is not the problem. My code works completely fine, and has done for many years.

My issue is that when I work locally on my development setup, I can’t display anything using GHOST. My homepage loads, but the Ghost section is always completely empty.

Since my code works on production, I’ve clearly got something setup incorrectly and was curious if there is something obvious I’ve missed.

To reiterate:

  • my code works in production env, not development env.
  • my development env variables for GHOST_URL and GHOST_SECRET are working, and are the exact same as production
  • I can use simple curl commands (with variables) from the local machine and access full JSON data which proves my app should work fine.
  • no warnings or issues listed in rails logs about errors.
  • ghost data just does not pass to view on local dev.

Depending on how you installed the dev version of Ghost, you probably need a different api key. Content imports don’t include api keys if I recall correctly.

But wait, you said it works with curl? I’ve got nothing then…

I’m not using a Development version of Ghost.
My Rails app is connecting to a live Production version of Ghost.

But wait, you said it works with curl? I’ve got nothing then…

:laughing: Same!!!

And you can curl from the development box?

I am running curl from my local terminal (osx) to prove that there are no firewalls restricting me from accessing my production Ghost server, or any issues with my api ids. Always works fine and loads the expected json data.