File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 11from fastapi import FastAPI
2+ from fastapi .middleware .cors import CORSMiddleware
23from mangum import Mangum
34from backend .app .main import app
45
56# Update the application instance name to match the EB configuration
67application = app
78
8- # Add CORS middleware
9- from fastapi .middleware .cors import CORSMiddleware
9+ # Add CORS middleware with specific origins
10+ origins = [
11+ "https://getgit789.github.io" ,
12+ "https://getgit789.github.io/python-interpreter-online/" ,
13+ "http://localhost:5000" ,
14+ "http://127.0.0.1:5000"
15+ ]
16+
1017application .add_middleware (
1118 CORSMiddleware ,
12- allow_origins = [ "*" ], # Temporarily allow all origins for testing
19+ allow_origins = origins ,
1320 allow_credentials = True ,
1421 allow_methods = ["*" ],
1522 allow_headers = ["*" ],
23+ expose_headers = ["*" ],
24+ max_age = 3600
1625)
1726
1827# Create handler for AWS Lambda
1928handler = Mangum (application )
2029
2130if __name__ == "__main__" :
2231 import uvicorn
23- uvicorn .run (application , host = "0.0.0.0" , port = 5000 )
32+ uvicorn .run (application , host = "0.0.0.0" , port = 80 )
You can’t perform that action at this time.
0 commit comments