From 8bd9f0a33280a09012457f39d59527c7389a0812 Mon Sep 17 00:00:00 2001 From: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:57:50 -0400 Subject: [PATCH] fix: add CORS (#21) --- main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.py b/main.py index dc97ec1..1dcfc16 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ from fastapi import FastAPI, File, UploadFile, HTTPException, BackgroundTasks, Query +from fastapi.middleware.cors import CORSMiddleware import os from pydantic import BaseModel from enum import Enum @@ -16,6 +17,22 @@ PackageManifest.update_forward_refs() app = FastAPI() +app.add_middleware( + CORSMiddleware, + allow_origins=[ + # NOTE: When running remix in local dev, this is the URL + "http://localhost:8080", + # NOTE: When running `npm run build && npm run preview`, this is the URL + "http://localhost:4173", + # NOTE: This is where the UI gets hosted + "https://remix.ethereum.org", + "https://remix-alpha.ethereum.org", + "https://remix-beta.ethereum.org", + ], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) class TaskStatus(Enum):