In this case, the problem turned out to be attempting to send a response based on the request, without wrapping the logic in compute
. For for example:
router.get('/foo', ({ send, request }) => {
if (request.url) {
send('something')
} else {
send('something else')
}
})
The problem with the above code is that the handler is run at build time, so that the edge logic can be compiled. If you need compute a response based on the request, that code needs to run in the serverless cloud, at runtime. You do this by wrapping it in compute
:
router.get('/foo', ({ send, compute }) => {
compute(request => {
if (request.url) {
send('something')
} else {
send('something else')
}
})
})
The compute function ensures that the code contained within executes at runtime, in serverless, not at build time.