File tree Expand file tree Collapse file tree 3 files changed +271
-221
lines changed Expand file tree Collapse file tree 3 files changed +271
-221
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,11 @@ version = "0.2.0"
5
5
requires-python = " >=3.12"
6
6
dependencies = [
7
7
" flask>=3.1.1" ,
8
- " flask-mailman" ,
9
- " Flask_Limiter" ,
10
- " xhtml2pdf" ,
11
- " redis" ,
8
+ " flask-mailman>=1.1.1" ,
9
+ " Flask_Limiter>=3.12" ,
10
+ " xhtml2pdf>=0.2.17" ,
11
+ " redis>=6.4.0" ,
12
+ " flask-cors>=4.0.0" ,
12
13
" valkey>=6.1.0" ,
13
14
" gunicorn>=23.0.0" ,
14
15
" google-auth>=2.40.3" ,
Original file line number Diff line number Diff line change 3
3
from flask_mailman import Mail
4
4
from flask_limiter import Limiter
5
5
from flask_limiter .util import get_remote_address
6
+ from flask_cors import CORS
6
7
import os
7
8
import secrets
8
9
@@ -38,6 +39,24 @@ def build_valkey_uri():
38
39
app = app ,
39
40
storage_uri = build_valkey_uri (),
40
41
)
42
+ # Configure CORS with strict origin validation
43
+ ALLOWED_ORIGINS = [
44
+ "https://tenantfirstaid.com" ,
45
+ "https://www.tenantfirstaid.com" ,
46
+ ]
47
+
48
+ # Add localhost origins for development
49
+ if os .getenv ("ENV" , "dev" ) == "dev" :
50
+ ALLOWED_ORIGINS .extend (
51
+ [
52
+ "http://localhost:3000" ,
53
+ "http://127.0.0.1:3000" ,
54
+ "http://localhost:5173" , # Vite default
55
+ "http://127.0.0.1:5173" ,
56
+ ]
57
+ )
58
+
59
+ CORS (app , origins = ALLOWED_ORIGINS , supports_credentials = True )
41
60
42
61
# Configure Flask sessions
43
62
app .secret_key = os .getenv ("FLASK_SECRET_KEY" , secrets .token_hex (32 ))
You can’t perform that action at this time.
0 commit comments