Very strange behavior. I have a lambda function that returns a JSON object. The call is simple. Here is the result from function:invoke
netlify functions:invoke comments --querystring "id=1"
◈ "port" flag was not specified. Attempting to connect to localhost:8888 by default
{"data":[{"user":{"avatarUrl":"https://avatars.githubusercontent.com/u/3497069?v=4","name":"JeffML"},"datePosted":"2022-10-24T22:47:50Z","isEdited":false,"isAuthor":true,"body":"First comment"}]}
Via netlify dev
I can verify that within the application the call is correctly made and I get the expected JSON body returned, as above.
When I do a netlify build
and then run the app in a static server via server -s build
, the function call returns the index.html of the app. I can verify this by pasting in the function URL (http://localhost:40243/.netlify/functions/comments?id=1); this returns the same result as (http://localhost:40423), which is index.html.
Any insights?