Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions app/services/api/src/finquest_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ class Settings(BaseSettings):
API_VERSION: str = "0.1.0"
DEBUG: bool = True

# CORS Configuration
ALLOWED_ORIGINS: List[str] = [
"http://localhost:3000",
"http://localhost:3001",
"http://127.0.0.1:3000",
]
# CORS Configuration - stored as string, converted to list via property
ALLOWED_ORIGINS: str = "http://localhost:3000,http://localhost:3001,http://127.0.0.1:3000,https://tryfinquest.vercel.app"

@property
def allowed_origins_list(self) -> List[str]:
"""Parse CORS origins from comma-separated string to list"""
if not self.ALLOWED_ORIGINS:
return []
# Split by comma and strip whitespace, remove empty strings
origins = [origin.strip() for origin in self.ALLOWED_ORIGINS.split(",") if origin.strip()]
# Remove trailing slashes for consistency
return [origin.rstrip("/") for origin in origins]

# Server Configuration
HOST: str = "0.0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion app/services/api/src/finquest_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=settings.ALLOWED_ORIGINS,
allow_origins=settings.allowed_origins_list,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down
4 changes: 2 additions & 2 deletions app/services/api/src/finquest_api/routers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.orm import Session
from ..auth_utils import get_current_user
from ..db.models import User, OnboardingResponse, Suggestion
from ..db.session import get_session, SessionLocal
from ..db.session import get_session, SessionLocal, get_engine
from ..schemas import UpdateProfileRequest, SuggestionResponse
from ..services.llm.service import LLMService
from ..services.module_generator import ModuleGenerator
Expand All @@ -26,7 +26,7 @@ async def generate_suggestions_task(
user_id: str
):
"""Background task to generate suggestions"""
db = SessionLocal()
db = SessionLocal(bind=get_engine())
try:
user = db.query(User).filter(User.id == user_id).first()
if user:
Expand Down
3 changes: 2 additions & 1 deletion app/web/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_PUBLIC_SUPABASE_URL=url
NEXT_PUBLIC_SUPABASE_ANON_KEY=key
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_SITE_URL=http://localhost:3000
31 changes: 31 additions & 0 deletions app/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ Install dependencies:
pnpm install
```

### Environment Variables

Create a `.env.local` file in the `app/web/` directory with the following variables:

```bash
# Supabase Configuration (required)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

# API Configuration (optional - defaults to http://localhost:8000 for local dev)
NEXT_PUBLIC_API_URL=http://localhost:8000
```

**For Production (e.g., Vercel):**

- Set `NEXT_PUBLIC_API_URL` to `https://finquest-api.onrender.com`
- The API URL automatically switches based on the environment variable

### Supabase OAuth Configuration

For Google OAuth to work correctly in both development and production, you need to configure redirect URLs in your Supabase dashboard:

1. Go to your Supabase project dashboard
2. Navigate to **Authentication** → **URL Configuration**
3. Add the following to **Redirect URLs**:
- `http://localhost:3000/` (for local development)
- `https://your-production-domain.com/` (for production)
4. Set the **Site URL** to your production URL (or leave it as default)

**Important:** If localhost URLs are not whitelisted in Supabase, OAuth redirects will default to the Site URL, causing redirects to production even when running locally.

Then, run the development server:

````bash
Expand Down
2 changes: 1 addition & 1 deletion app/web/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
const { error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: `${window.location.origin}/`,
redirectTo: process.env.NEXT_PUBLIC_SITE_URL,
},
});

Expand Down
42 changes: 42 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
- type: web
name: finquest-api
runtime: python
plan: free
buildCommand: cd app/services/api && pip install uv && uv python install 3.9 && uv python pin 3.9 && uv sync
startCommand: cd app/services/api && uv run uvicorn finquest_api.main:app --host 0.0.0.0 --port $PORT
envVars:
- key: PYTHON_VERSION
value: 3.9.0
- key: PORT
value: 8000
- key: UV_PYTHON_DOWNLOADS
value: manual
# Supabase Configuration - Set these in Render dashboard
- key: SUPABASE_URL
sync: false
- key: SUPABASE_KEY
sync: false
- key: SUPABASE_JWT_SECRET
sync: false
- key: SUPABASE_DB_URL
sync: false
# LLM Configuration - Set these in Render dashboard
- key: LLM_PROVIDER
value: gemini
- key: LLM_BASE_URL
value: https://generativelanguage.googleapis.com/v1beta
- key: LLM_MODEL
value: gemini-2.0-flash
- key: LLM_API_KEY
sync: false
- key: LLM_ORG_ID
sync: false
- key: LLM_TIMEOUT_SECONDS
value: 30.0
- key: LLM_MAX_RETRIES
value: 2
# CORS Configuration - Update with your frontend URL
- key: ALLOWED_ORIGINS
value: http://localhost:3000,http://localhost:3001,http://127.0.0.1:3000,https://tryfinquest.vercel.app

Loading