In this repo I have the branch “svelte”, which contains all the code reflecting the current problem I am having:
As can be seen, this is a project using a monorepo format. The frontend folder contains the Svelte frontend, which is correctly working, I can visit the website via the preview link and navigate correctly.
The backend folder, contains the api folder with the api endpoint, and the src folder with the core logic for the serverless function.
However, when in the website I make a click that makes a api call to the “generate_plot” serverless function, I get the following error in the Vercel Log:
As can be seen, it says /api/generate_plot was not found. A stranger thing perhaps, is that it reports on the right that the called route is `/![-]/catchall. I am not sure how to fix this.
This is my vercel.json:
{
"version": 2,
"builds": [
{
"src": "frontend/package.json",
"use": "@vercel/static-build",
"config": {
"cwd": "frontend",
"distDir": ".vercel/output"
}
},
{
"src": "backend/api/**/*.py",
"use": "@vercel/python",
"config": {
"runtime": "python3.12",
"memory": 1024,
"includeFiles": [
"backend/src/**",
"backend/requirements.txt"
]
}
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "/backend/api/$1"
},
{
"handle": "filesystem"
}
]
}
Note: initially I tried to run the project without the builds field in vercel.json, however, then visualizing the website preview I was just getting a 404 not found error. Defining the build for the frontend fixed that issue.
How to fix this?

