#x-appwrite-user-id missing from function context headers
13 messages · Page 1 of 1 (latest)
i should add i'm using anonymous login on the frontend
to be more precise. i am checking "context.req.headers" in the function. and the x-appwrite-user-id is an empty string
ah ok i see i need to run appwrite run functions with --user-id honestly this is pretty lame, it should grab the user id automatically if it's an appwrite cloud project.
This is also not helped by the fact that the local dev hotload is currently broken - thus leading users to assume the local server is just buggy.
so tldr: suggestion for you guys to focus on local dev flow with appwrite cloud projects, especially python
The fronted can't pass that header. That header is automatically added by the backend
I mean, by appwrite itself
When you make a request form the frontend, with an authenticated user
yes that's what i realized later but it makes it difficult to simulate getting requests from different users as per later msgs. ive noticed local dev in general with appwrite is a bit clunky
If you manage to override it from the client, you discovered a security vulnerability.
It's immutable for security purposes.
You could add another header for testing it and specify a custom user ID.
Remember to delete the code related to it when running in production.
yes i understand overwriting from client is not what we want. all i was saying is that it would be nice if the local function runtime automatically pulled in the user id from appwrite cloud if it detected those cookies present
this was helpful for me on a related issue, @hollow sage thanks for asking
glad it helped @vast snow . hopefully appwrite improves their local dev flow. also, i found a way to patch the bug where local hotloading doesnt work incase they havent released that appwrite cli update yet. lmk if you run into that issue and i can maybe help
You've tried createExecution?
const client = new Client();
const functions = new Functions(client);
client
.setProject('<PROJECT_ID>') // Your project ID
;
const promise = functions.createExecution(
'<FUNCTION_ID>', // functionId
'<BODY>', // body (optional)
false, // async (optional)
'<PATH>', // path (optional)
'GET', // method (optional)
{} // headers (optional)
);
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});