Back

Appwrite Fucntion req.get('authorization') Not Working

  • 0
  • Functions
  • Cloud
Zionnite
14 Apr, 2024, 00:23

Hello guys, from the api docuation of livekit.io https://docs.livekit.io/realtime/server/webhooks/#Receiving-webhooks, it is stated that to recieve webhook the `req.get('authorization') will need to be called, but calling it in Appwrite Cloud function its outputting

TypeScript
    at Module.default (file:///usr/local/server/src/function/src/main.js:29:48)
    at execute (/usr/local/server/src/server.js:157:48)
    at async action (/usr/local/server/src/server.js:174:13)
    at async /usr/local/server/src/server.js:10:9```

 How can this be resolved?
TL;DR
Appwrite developers are facing an issue with the `req.get('authorization')` function in Appwrite Cloud functions. The proper way to access the authorization header in Appwrite is through `req.headers["Authorization"]`. This method is different from Express. Check the Appwrite Functions documentation for more clarity on request handling.
Ryan
14 Apr, 2024, 00:35

The request object in Appwrite Functions is slightly different to what would normally be expected in Express, this might give a clearer idea as to what you're looking for https://appwrite.io/docs/products/functions/develop#request

Ryan
14 Apr, 2024, 00:37

It looks like it's trying to get the value of the authorization header which I think is done like this

TypeScript
const authorization = req.headers["Authorization"];

I'm not sure if that's 100% correct as I'm trying to do it from memory but the link I sent will give a much better idea as to what you need to be doing

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more