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?
Yes. I gave the app write full access to all my GitHub repos. If that's what you mean
It should be any
What should be any ?
What do you see here?
The permission, under the settings tab
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?
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?
Just a moment Luke. Brb
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 middleware
import { accessRoute } from "./middleware/accessRoute";
// error handler middleware
import { errorHandler } from "./middleware/errorHandler";
import { notFound } from "./middleware/notFound";
// routers
import authRouter from "./routes/auth";
import planRouter from "./routes/plan";
import payStackRouter from "./routes/paystack";
import profileRouter from "./routes/profile";
app.set("trust proxy", 1);
// cors
app.use(helmet());
app.use(
cors({
origin: [
"http://localhost:3001",
"http://127.0.0.1:5500",
"http://localhost:5500",
],
})
);
// body parsing middleware / other middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(errorHandler);
// routes
app.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 middleware
app.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
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
I'll give this a read. Thanks
No worries! Good luck with your project <:appwriterocket:823996226894692403>
Thanks for the help @Madhawa. @ZeroH feel free to ping us if the problem still exists ๐
Recommended threads
- TablesDB `updateRows` returns `database_...
Hi Appwrite team! Iโm seeing a strange issue with TablesDB bulk row updates on a self-hosted Appwrite instance. **Environment** - Appwrite self-hosted `1.9.0` ...
- [SOLVED] Realtime Missing Channels
```js useEffect(() => { let subscription: RealtimeSubscription; async function loadChips() { try { const {rows: chi...
- Functions executed by events does not ap...
Hello, Running self-hosted Appwrite version 1.9.0 (with console 7.8.26). When functions are triggered by an event (eg. databases.\*tables.\*.rows.\*.create) doe...