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
- Added Custom Domain - API requests with ...
I've added in a custom domain to Appwrite my domain itself is on cloudflare but has Appwrite name servers added and confirmed they work, I added the CAA in clou...
- Table contents missing (attributes+rows)
Here is an image of the cloud and the attributes that should exist Some of the table do have the data but others dont. I am able to access the rows via api c...
- Bug Report: type generation for enum of ...
### π Reproduction steps in the enum element value, instead of English, use another language (Khmer), in my case Khmer text. ``` export enum ProvinceType { ...