Deployment URL or Custom Domain: [Your deployment URL]
Environment: production
Project Framework: Flask/React
Build Settings:
Framework Preset: Other
Build Command: N/A (Pre-built React)
Output Directory: N/A
Install Command: pip install poetry && poetry install
Node/Runtime Version: Python 3.10
Package Manager: Poetry
Relevant Packages: flask, flask-sqlalchemy, python-dotenv, authlib, supabase
Issue Synopsis:
I’m experiencing deployment issues with a Flask application that serves a pre-built React frontend. The React build is integrated into Flask’s directory structure before deployment, with built files residing in the backend/golf/static directory and index.html in backend/golf/blueprints/page/templates.
Current Behavior:
The deployment fails with two distinct errors:
- Module import error: Unable to import ‘golf’ module
- HTTP handler error with issubclass() argument
Expected Behavior:
The Flask application should serve the pre-built React files from its directory structure and handle API routes, connecting to Supabase for database operations and Auth0 for authentication.
Project Structure: (See Attached Mermaid Diagram)
My application uses a modular structure where the frontend is pre-built and integrated into the Flask backend before deployment. The backend directory contains the complete application with all static assets and templates already in place.
Reproduction Steps:
- Push code to GitHub repository
- Vercel attempts deployment
- Deployment fails at Python runtime initialization
Configuration:
{
"version": 2,
"builds": [
{
"src": "backend/golf/app.py",
"use": "@vercel/python",
"config": {
"runtime": "python3.10"
}
}
],
"routes": [
{
"src": "/(.*)",
"dest": "backend/golf/app.py"
}
],
"env": {
"FLASK_APP": "golf.app:create_app"
}
}
Attempted Solutions:
- Modified PYTHONPATH settings
- Tried different root directory configurations
- Experimented with various vercel.json configurations
- Tested different Python runtime configurations
The application works perfectly in local development using Docker, suggesting the issues are specific to Vercel’s serverless environment.
Primary concerns are:
- Correct module import configuration
- Proper handling of the Flask application in Vercel’s serverless context
- Appropriate configuration for serving static files
- Poetry dependency management in the Vercel environment
Additional Information:
- Using Supabase for PostgreSQL in production
- Integrated with Auth0 for authentication
- Frontend is pre-built and integrated before deployment
- Using Poetry for dependency management
Could you please provide guidance on:
- Correct configuration for Flask applications with integrated frontend assets
- Proper PYTHONPATH setup for modular Flask applications
- Best practices for Poetry-managed Python applications on Vercel
- How to correctly configure my vercel.json file for subsequent Github commits and vercel deploys.
Directory Tree (From my codebase):