@@ -72,6 +72,9 @@ SECRET_SECRET_KEY_VERSION=v1 # length=64
|
||||
# GITEA_ACCOUNT_LINKING=replace-me
|
||||
# GITEA_OAUTH2_CLIENT_ENABLED=replace-me
|
||||
|
||||
# CORS (for Decap CMS, Sveltia CMS etc.)
|
||||
# GITEA_CORS_ALLOW_DOMAIN=https://cms.example.com,https://other.example.org
|
||||
|
||||
# Lifetime of an OAuth2 refresh token in hours, prolly no need to edit. We
|
||||
# were hitting issues with infrequently pushed to repos that were not picked
|
||||
# up by drone after a month of inactivity, hence the option.
|
||||
|
||||
@@ -71,3 +71,17 @@ ssh -T -p 2222 git@my.gitea.example.com
|
||||
```
|
||||
|
||||
Note that gitea should be configured to listen to port 2222, i.e. `GITEA_SSH_PORT=2222` in the gitea config.
|
||||
|
||||
## CORS
|
||||
|
||||
To let a browser app on another domain (Decap CMS, Sveltia CMS) use the API:
|
||||
|
||||
```sh
|
||||
GITEA_CORS_ALLOW_DOMAIN=https://cms.example.com
|
||||
```
|
||||
|
||||
Full origins, comma-separated for more than one. Check with:
|
||||
|
||||
```sh
|
||||
curl -sI -H 'Origin: https://cms.example.com' https://my.gitea.example.com/api/v1/version | grep -i access-control
|
||||
```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export APP_INI_VERSION=v23
|
||||
export APP_INI_VERSION=v24
|
||||
export DOCKER_SETUP_SH_VERSION=v1
|
||||
export PG_BACKUP_VERSION=v1
|
||||
|
||||
|
||||
@@ -72,6 +72,12 @@ REVERSE_PROXY_LIMIT = 1
|
||||
REVERSE_PROXY_TRUSTED_PROXIES = *
|
||||
SECRET_KEY = {{ secret "secret_key" }}
|
||||
|
||||
{{ if ne (env "GITEA_CORS_ALLOW_DOMAIN") "" }}
|
||||
[cors]
|
||||
ENABLED = true
|
||||
ALLOW_DOMAIN = {{ env "GITEA_CORS_ALLOW_DOMAIN" }}
|
||||
{{ end }}
|
||||
|
||||
[admin]
|
||||
DISABLE_REGULAR_ORG_CREATION = {{ env "GITEA_DISABLE_REGULAR_ORG_CREATION" }}
|
||||
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ services:
|
||||
app:
|
||||
deploy:
|
||||
labels:
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=anubis,${STACK_NAME}_cors"
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=anubis"
|
||||
|
||||
@@ -81,12 +81,6 @@ services:
|
||||
- "traefik.tcp.routers.${STACK_NAME}-ssh.rule=HostSNI(`*`)"
|
||||
- "traefik.tcp.routers.${STACK_NAME}-ssh.entrypoints=gitea-ssh"
|
||||
- "traefik.tcp.services.${STACK_NAME}-ssh.loadbalancer.server.port=${GITEA_SSH_PORT}"
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}_cors"
|
||||
- "traefik.http.middlewares.${STACK_NAME}_cors.headers.accesscontrolallowmethods=GET,OPTIONS,PUT"
|
||||
- "traefik.http.middlewares.${STACK_NAME}_cors.headers.accesscontrolallowheaders=content-type,authorization"
|
||||
- "traefik.http.middlewares.${STACK_NAME}_cors.headers.accesscontrolalloworiginlist=https://${GITEA_CORS_ALLOW_DOMAIN}"
|
||||
- "traefik.http.middlewares.${STACK_NAME}_cors.headers.accesscontrolmaxage=100"
|
||||
- "traefik.http.middlewares.${STACK_NAME}_cors.headers.addvaryheader=true"
|
||||
- coop-cloud.${STACK_NAME}.version=3.6.7+1.27.3-rootless
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
CORS is now handled by Gitea itself ([cors] in app.ini) instead of a traefik
|
||||
headers middleware. If you set GITEA_CORS_ALLOW_DOMAIN, it now takes full
|
||||
origins rather than bare hostnames, so change
|
||||
|
||||
GITEA_CORS_ALLOW_DOMAIN=cms.example.com
|
||||
|
||||
to
|
||||
|
||||
GITEA_CORS_ALLOW_DOMAIN=https://cms.example.com
|
||||
|
||||
before upgrading, or browser requests from that site will start failing.
|
||||
Several origins can be listed, comma-separated.
|
||||
Reference in New Issue
Block a user