Back
CORS preflight returns 500 on Dart function (context.res.text() / .empty() not found)
- 0
- Functions
- Cloud
Hey everyone 👋
I’m running a Dart cloud function, Every time I respond to a preflight (OPTIONS) request, I get a 500 internal error, and the logs show:
NoSuchMethodError: Class 'RuntimeResponse' has no instance method 'text' or 'empty'
I've treid these
TypeScript
return context.res.empty(status: 204, headers: headers);
return context.res.json({}, 204, headers);````
None of them seem to exist on the runtime’s context.res.
❓ So I’m wondering:
• Which context.res methods are actually available in the Dart 3.x Appwrite runtime?
• Is there an updated way to send a plain response with custom headers (e.g. for CORS preflight)?
TL;DR
Issue: Developers facing 500 error in Dart cloud function while responding to preflight request, context.res.text() / .empty() not found.
Solution: In Dart 3.x Appwrite runtime, available methods for context.res are limited. Update method to send a plain response with custom headers:
`context.res.setHeader('Content-Type', 'text/plain');
context.res.setStatusCode(204);
context.res.send('');`Recommended threads
- Problem with the new Email policies
when user set those thing from cloud panel and when they open that page again or reload that time it forget what we have checked and it set default to false on ...
- Deleted my account, trying to signup aga...
https://cloud.appwrite.io/console/login?error=%7B%22message%22%3A%22This+email+address+must+already+be+in+its+canonical+form.+Please+remove+aliases%2C+tags%2C+o...
- Unable to create Sites or Functions with...
Heya, I was looking at the appwrite documentation for Sites API with the server api: https://appwrite.io/docs/references/cloud/server-nodejs/sites I can’t fin...