From 3714a2438be487dd98cddef3384425127a011528 Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Sun, 22 Mar 2026 10:59:33 +0000 Subject: [PATCH] Add CORS, welcome message and README cleanup Enable CORS middleware to allow cross-origin requests during development and from specified domains (http://localhost:1999, https://goldlabel.pro, https://soho.goldlabel.pro). Add a friendly "Welcome to NX AI!" message to the root API response. Tidy README venv/installation instructions by consolidating the virtualenv activation and removing redundant comment lines. --- README.md | 7 +------ app/api/root.py | 1 + app/main.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 501f854..1ffa2aa 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,9 @@ Create an environment file and add Postgres credentials etc `cp .env.sample .env` ```bash -# Create and activate a virtual environment python -m venv venv -source venv/bin/activate # Windows: venv\Scripts\activate - -# Install dependencies +source venv/bin/activate pip install -r requirements.txt - -# Start development server uvicorn app.main:app --reload ``` diff --git a/app/api/root.py b/app/api/root.py index 3cd4c24..ce376e7 100644 --- a/app/api/root.py +++ b/app/api/root.py @@ -19,6 +19,7 @@ def root() -> dict: "base_url": base_url, "time": epoch, "severity": "success", + "message": "Welcome to NX AI!" } endpoints = [ {"docs": "docs", "url": f"{base_url}/docs"}, diff --git a/app/main.py b/app/main.py index 26bbb30..4ade825 100644 --- a/app/main.py +++ b/app/main.py @@ -3,6 +3,7 @@ from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse import os @@ -16,6 +17,18 @@ version=__version__, ) +# CORS middleware for development +app.add_middleware( + CORSMiddleware, + allow_origins=[ + "http://localhost:1999", + "https://goldlabel.pro", + "https://soho.goldlabel.pro", + ], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"] +) app.include_router(router)