I was looking at the documentation of the new Netlify Edge Functions, where there is a concept of calling await next()
in a handler: Edge Functions API | Netlify Docs. This allows the following really nice pattern:
export default (req, ctx) => {
const auth = checkAuth();
// Forbidden
if(!auth) return new Response(null, {status: 403});
// User is authenticated, continue request as normal
return await ctx.next();
}
Which allows you to sort of ‘protect’ assets. For example, I might have some images that I would only want authenticated users to be able to see, I could put a route handler like this in between, using Edge Functions.
The problem is; I already have an existing app, and it uses some Nodejs libraries that are not supported in Deno. So I won’t be able to migrate my app to Edge Functions any time soon. I cannot, however, find a similar kind of next
functionality in the ‘regular’ Netlify Functions. Could anyone point out to me if the pattern I described would be possible using ‘regular’ Netlify Functions? Could I potentially make a feature request, even?