This is both a “Can I” and “Should I” type question. Imagine a scenario where I’ve built a serverless function that needs to output data that my static site is using. So for example, in an Eleventy site I’ve defined a JSON data file of cats. I output this both as a set of HTML files (list of cats and unique cat page) as well as /cats.json
. I want my serverless function to be able to read /cats.json
. I could do it with a HTTP request, but that would mean a HTTP request to my serverless function needs to essentially do a HTTP request to my own site.
So I guess my question is, given .functions/foo/foo.js, can I do a file read on /cats.json to get data?
The idea is - my serverless function logic is written once, but the data it uses is controlled by the JSON file generated itself by data that drives the HTML of my static site.
I don’t think I did a great job explaining that so let me know what I can clarify.