From 1756a3bff7c20981ab81d1f02e5a124b68b0611f Mon Sep 17 00:00:00 2001 From: khorshuheng Date: Sat, 11 Jan 2025 23:57:46 +0800 Subject: [PATCH] fix: add cors for nginx gotrue configuration --- docker-compose.yml | 1 + nginx/nginx.conf | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7e3e22eb4..5187baecf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -137,6 +137,7 @@ services: - AI_SERVER_PORT=${AI_SERVER_PORT} - AI_OPENAI_API_KEY=${AI_OPENAI_API_KEY} # Uncomment this line if AppFlowy Web has been deployed + # - APPFLOWY_WEB_URL=${APPFLOWY_WEB_URL} build: context: . dockerfile: Dockerfile diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 1f4bd1dee..6712da4ec 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -49,6 +49,17 @@ http { # GoTrue location /gotrue/ { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' $cors_origin always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Headers' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always; + add_header 'Access-Control-Max-Age' 3600 always; + add_header 'Content-Type' 'text/plain charset=UTF-8' always; + add_header 'Content-Length' 0 always; + return 204; + } + proxy_pass $gotrue_backend; rewrite ^/gotrue(/.*)$ $1 break;