Web Developer
I've hosted my function. When I visit the associated app write domain, I get the error
Error 400
Execution error: No permissions provided for action 'execute'
Type
general_argument_invalid
What's the fix?
Votes
0
Replies
21
Participants
Unknown
Messages
22
Web Developer
I've hosted my function. When I visit the associated app write domain, I get the error
Error 400
Execution error: No permissions provided for action 'execute'
Type
general_argument_invalid
What's the fix?
Are the permissions added correctly?
Web Developer
Yes. I gave the app write full access to all my GitHub repos. If that's what you mean
It should be any
Web Developer
What should be any ?
What do you see here?
The permission, under the settings tab
Web Developer
It wasn't checked but I've set it as any. The page isn't loading anymore
Can you refresh once again? Or try a little later and then let me know if that works?
Web Developer
Alright
What do you see in the execution logs?
Are you able to share the code for the function?
What runtime version are you using?
Web Developer
Just a moment Luke. Brb
Web Developer
I see failed under status in the execution log.
Here is the code for the function
import express, { Request, Response } from "express";const app = express();import "dotenv/config";import helmet from "helmet";import "express-async-errors";import connectDB from "./db/connect";import cors from "cors";// accessRoute middlewareimport { accessRoute } from "./middleware/accessRoute";// error handler middlewareimport { errorHandler } from "./middleware/errorHandler";import { notFound } from "./middleware/notFound";// routersimport authRouter from "./routes/auth";import planRouter from "./routes/plan";import payStackRouter from "./routes/paystack";import profileRouter from "./routes/profile";
app.set("trust proxy", 1);
// corsapp.use(helmet());app.use( cors({ origin: [ "http://localhost:3001", "http://127.0.0.1:5500", "http://localhost:5500", ], }));
// body parsing middleware / other middlewareapp.use(express.json());app.use(express.urlencoded({ extended: true }));app.use(errorHandler);
// routesapp.get("/", (req: Request, res: Response): void => { res.send("<h1>Hello World!</h1>");});app.use("/api/v1/auth", authRouter);app.use("/api/v1/plan", accessRoute, errorHandler, planRouter);app.use("/api/v1/paystack", payStackRouter);app.use("/api/v1/profile", profileRouter);
// 404 error handler middlewareapp.all("*", notFound);
const PORT = process.env.PORT || 3000;
app.listen(PORT, async (): Promise<void> => { if (typeof process.env.MONGO_URI === "undefined") { throw new Error("MONGO_URI is not defined"); } await connectDB(process.env.MONGO_URI); console.log(`Server is running on port ${PORT}...`);});I'm using Node 18.x
Your function is using express which won't interface with our Appwrite functions runtime. You'll need to use a function entrypoint like seen in the examples here: https://appwrite.io/docs/products/functions/development#life-cycle
Alternatively, if you want to use express, you may be able to write some kind adapter to call your express handlers from our runtime.
cc @ZeroH
Web Developer
Noted. I'll try to make the necessary changes.
I did see this project which uses HonoJS server with appwrite runtime, maybe it can help you https://github.com/kit-t/lhci-server-appwrite/tree/main/functions/lighthouse-server/src
Web Developer
I'll give this a read. Thanks
No worries! Good luck with your project 
Thanks for the help @Madhawa. @ZeroH feel free to ping us if the problem still exists 🙂