Issues implementing Flask Python API alongside the standard Next.js App router API
Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
Hello! I have been trying for a while now to write a dedicated python endpoint for my app. I use Next.j 13 with the App router and already have an api folder. I implemented all the steps from the flask-starter-template: https://vercel.com/templates/next.js/nextjs-flask-starter
It works locally but when I deploy to Vercel the python serverless functions are not recognized. I think the most likely issue is that I have two api folders:
/api/
--index.py
/app/
--api/
...
--route.ts
What I have tried so far:
- Rename the python api folder
- Place the index.py inside a folder inside the python api folder
- Place the index.py into the app api folder
Of course I changed my next.config.js accordingly each time:
Does anyone have an idea on how to tackle this?
It works locally but when I deploy to Vercel the python serverless functions are not recognized. I think the most likely issue is that I have two api folders:
/api/
--index.py
/app/
--api/
...
--route.ts
What I have tried so far:
- Rename the python api folder
- Place the index.py inside a folder inside the python api folder
- Place the index.py into the app api folder
Of course I changed my next.config.js accordingly each time:
const nextConfig = {
rewrites: async () => {
return [
{
source: '/api/python/:path*',
destination:
process.env.NODE_ENV === 'development'
? 'http://127.0.0.1:5328/api/python/:path*'
: '/api/python',
},
]
},
}Does anyone have an idea on how to tackle this?