Connecting to a pure lambda functions server, locally and remote

(Note: function folder was ‘pgnfen’, now ‘server’)

I’m trying to split a project into 1) a lambda functions server & 2) a web client that calls it. A couple of issues.

a) when launching the server locally (via netlify dev), I seem to get a random port #. I think this may be addressed elsewhere (-p flag?).

b) I’m using Apollo GraphQL client. It is configured like so:

const httpLink = createHttpLink({
  uri: '/.netlify/functions/pgnfen',
});

const authLink = setContext((_, { headers }) => {
//...
});

const client = new ApolloClient({
  link: authLink.concat(httpLink),
  cache: new InMemoryCache(),
});

So do I just stick a local (or remote) server address before the uri value? Something like:

  1. uri: http://localhost:12345/.netlify/functions/pgnfen (local)
  2. uri: https://pgnfen.netlify.app/.netlify/functions/pgnfen (remote)

Anything else you can think of?

Okay, I tried the full path link to localhost, but I get a “No data found for resource with given identifier” response. Details as follows:

image

const httpLink = createHttpLink({
  uri: 'http://localhost:8881/.netlify/functions/server',
});

const authLink = setContext((_, { headers }) => {
...
});

const client = new ApolloClient({
  link: authLink.concat(httpLink),
  cache: new InMemoryCache(),
});

The request (from localhost:8888):

Payload:

It seems like the localhost:8888 request is not finding the functions endpoint on localhost:8881.

Got past the above issue as described here. Specifically,

  1. go to chrome://flags/#block-insecure-private-network-requests
  2. set Block insecure private network requests to Disabled

Now I am getting a “Function not found…” error, which I’ll address in another ticket