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; + } +```