32
loading...
This website collects cookies to deliver better user experience
./functions
folder full of individual files that did CRUD operations. It worked, but it was a bit of a mess to work with.your.app/.netlify/functions/api
to your.app/api
- see this Tweet for the ‘official’ recommendationcontext.clientContext.user
which contains the claims of the respective user. Checking that in api.js (and any other non-public function that’s used by the app) makes sure that only authenticated users can use the application. See Protecting Endpoints for further details and explanations.netlify.toml
will only apply to the HTML responses of requests to your site; functions need to return their own (secure) headers - see: Is it possible to fetch a netlify function from another domain.const fnHeaders = require('./_shared/headers.js');
...
return callback(null, {
statusCode: 200,
headers: { ...fnHeaders },
body: JSON.stringify(apiData)
})
32