Home
Support Forums

Serverless Function working locally but not on production

Hiya!

Getting this error in the deploy logs:

FetchError: invalid json response body at https://practical-carson-74e9d3.netlify.app/.netlify/functions/getHomepageStory reason: Unexpected token < in JSON at position 0 at file:///opt/build/repo/src/pages/index.astro

The site works fine locally using ntl dev & ntl build, using the function to fetch JSON from the Storyblok headless CMS using their SDK. Here’s a link to the GH repo, specifically the function:

Any feedback would be super appreciated!

I’m seeing a 404 for the link you shared above.

However, from this line:

it appears that you’re trying to read a file using a file protocol?

Also, on a side note, you don’t need to use dotenv in Functions.