From 380980d66fa5927baf30b3c4c1b191eca21e7997 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Sun, 9 Oct 2022 10:13:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20gitea=E5=BA=94=E7=94=A8=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/部署之Gitea应用创建.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/部署之Gitea应用创建.md b/docs/部署之Gitea应用创建.md index 0e284f87..8dfd4f24 100644 --- a/docs/部署之Gitea应用创建.md +++ b/docs/部署之Gitea应用创建.md @@ -20,4 +20,16 @@ # Gitea跨域问题 -由于StackEdit中文版是从浏览器直接访问Gitea接口,故个人部署的Gitea需要支持跨域,至于如何支持跨域,请参考官方文档:https://docs.gitea.io/en-us/config-cheat-sheet/#cors-cors +由于StackEdit中文版是从浏览器直接访问Gitea接口,故个人部署的Gitea需要支持跨域,至于如何支持跨域,请参考官方文档:https://docs.gitea.io/en-us/config-cheat-sheet/#cors-cors (官方跨域的支持好像存在问题,我个人包括很多网友通过这个配置支持跨域都失败了,如果你也失败了,可以试试用nginx代理实现跨域) + +nginx配置实现跨域的配置如下: + +``` + add_header Access-Control-Allow-Headers *; + add_header Access-Control-Allow-Origin $http_origin; + add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS; + + if ($request_method = 'OPTIONS') { + return 204; + } +```