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 — 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
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.
I can put the json files here and they are readable:
So this fixes it :)
Nice! That’s a good workaround. Just confirming the original bug has been fixed and will be released in v5.0