From 85c94f954a9766aa328ce61af7a979321b7ecb07 Mon Sep 17 00:00:00 2001 From: Christian Boettcher <c.boettcher@fz-juelich.de> Date: Mon, 14 Mar 2022 11:47:45 +0100 Subject: [PATCH] add cors to python backend --- apiserver/main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apiserver/main.py b/apiserver/main.py index 5b81c44..85ffa70 100644 --- a/apiserver/main.py +++ b/apiserver/main.py @@ -12,6 +12,7 @@ from fastapi import FastAPI, HTTPException, Request, status from fastapi.param_functions import Depends from fastapi.responses import JSONResponse from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm +from fastapi.middleware.cors import CORSMiddleware from pydantic import UUID4 from starlette.responses import RedirectResponse @@ -40,6 +41,24 @@ app = FastAPI( title="API-Server for the Data Catalog" ) +origins = [ + "https://datacatalog.fz-juelich.de", + "https://datacatalogue.eflows4hpc.eu", + "https://zam10059.zam.kfa-juelich.de", + "https://zam10036.zam.kfa-juelich.de", + "http://datacatalog.fz-juelich.de", + "http://datacatalogue.eflows4hpc.eu", + "http://zam10059.zam.kfa-juelich.de", + "http://zam10036.zam.kfa-juelich.de" +] + +app.add_middleware(CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"] +) + # if env variable is set, get config .env filepath from it, else use default dotenv_file_path = os.getenv(DOTENV_FILE_PATH_VARNAME, DOTENV_FILE_PATH_DEFAULT) -- GitLab