const { clinicRef, patientRef }: CreateConsultationData = req.body;
const databases = new Databases(client);
const teams = new Teams(client);
const functions = new Functions(client);
const { "x-appwrite-user-id": creator }: RequestHeaders = req.headers;
log(JSON.stringify(req.headers));
if (!creator) {
return res.send(
JSON.stringify({
message: "x-appwrite-user-id header is required",
}),
404,
{
"content-type": "application/json",
}
);
}
The result is the second image
How to set a header on provided domain of specific appwrite?
I see I am not allowed to use that contains x-appwrite
Of course...it's automatically set by Appwrite
Do you have to use that function domain?
nope just for testing
I know that we have the rest api for function, but this makes me easy to set up hehe
When you execute a function like this, it's an unauthenticated request so Appwrite doesn't pick up the user and it doesn't set the user id and JWT headers
ohh I see I implement this as my alternative solution
const { "x-appwrite-user-id": userId, "user-id": backup }: RequestHeaders =
req.headers;
const databases = new Databases(client);
const authorId = userId || backup;
if (!authorId) {
return res.send(
JSON.stringify({
message: "either x-appwrite-user-id or user-id header is required",
}),
404,
{
"content-type": "application/json",
}
);
}
I added user-id just for testing so I can use it to my postman
Recommended threads
- Failed function deployments
I am using appwrite 1.8.0 (self hosted) and trying to manually deploy a python function. I am using appwrite from 0.x and went through multiple migrations. So ...
- Python-ml-3.12
Hi, when this runtime will be available for the cloud. I could see the runtimes repo has this added to Runtimes.php but I'm not able to use it to run locally or...
- Function Building show 500 Error
Region: sfo Temple: Starter Function Runtime: Nodejs 22 What happened? Before 2 minutes it show ‘server error.","code":500,"version":"0.7.24"}’ after it show c...