Json asset file goes to 404

I’m trying to access a json asset file that I added to /assets/js/test.json
When I go to http://localhost:2370/assets/js/test.json it brings me to a 404 page.

I’m trying to load this file using a js script, but I’m getting this in the console:

GET http://localhost:2370/assets/js/test.json/ 404 (Not Found)

When I try to go to http://localhost:2370/assets/js/main.js it loads the js file as expected.

So my question is, how can I make sure ghost recognizes json files? Or what is causing this?
I’ve tried different json files at different locations, but all result in the same.

Hey @Kenji_Bailly :wave: — sorry about this, I just verified the same behaviour. We block json files in themes to prevent things like package.json being served. This should probably only apply in the root theme directory, but at the moment it looks like it applies to all directories - which is a bug.

I’ve passed this along to the team to track and improve in future. Unfortunately at the moment if you want to access a JSON file you’d need to host it outside Ghost, perhaps using something like a Cloudflare Worker

1 Like

Thank you for the quick answer. Hopefully this will be fixed soon since I’m planning on using json files as 3D objects to show on my site which will be quite a few.

EDIT:

I can put the json files here and they are readable:

/content/files/json

So this fixes it :)

2 Likes

Nice! That’s a good workaround. Just confirming the original bug has been fixed and will be released in v5.0

1 Like

Alright thank you :)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.