Add new env variable to use prefixes in url [release-patch] #8
@@ -75,6 +75,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config user.name "Gitea CI"
|
git config user.name "Gitea CI"
|
||||||
git config user.email "ci@git.theprivateserver.de"
|
git config user.email "ci@git.theprivateserver.de"
|
||||||
|
|
||||||
|
- name: Determine branch to push to
|
||||||
|
id: push_branch
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
|
# workflow_dispatch runs on a branch ref like refs/heads/main
|
||||||
|
BRANCH=${GITHUB_REF#refs/heads/}
|
||||||
|
else
|
||||||
|
# for a merged PR use the PR base ref (target branch)
|
||||||
|
BRANCH=${{ github.event.pull_request.base.ref }}
|
||||||
|
fi
|
||||||
|
echo "PUSH_BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||||
- name: Bump version
|
- name: Bump version
|
||||||
id: bump
|
id: bump
|
||||||
run: |
|
run: |
|
||||||
@@ -133,7 +145,7 @@ jobs:
|
|||||||
uses: ad-m/github-push-action@master
|
uses: ad-m/github-push-action@master
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
branch: ${{ github.ref }}
|
branch: ${{ env.PUSH_BRANCH }}
|
||||||
- name: Build Changelog
|
- name: Build Changelog
|
||||||
id: build_changelog
|
id: build_changelog
|
||||||
uses: https://github.com/mikepenz/release-changelog-builder-action@v5
|
uses: https://github.com/mikepenz/release-changelog-builder-action@v5
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: semapform-image
|
name: semapform-image
|
||||||
path: semapform-api.tar
|
path: semapform-api.tar
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
smoke-tests:
|
smoke-tests:
|
||||||
needs: build-image
|
needs: build-image
|
||||||
|
|||||||
@@ -12,6 +12,28 @@ from fastapi.responses import JSONResponse
|
|||||||
|
|
||||||
app = FastAPI(title="Signature Validation API")
|
app = FastAPI(title="Signature Validation API")
|
||||||
|
|
||||||
|
# Optional path prefix support: when behind a reverse-proxy that uses a
|
||||||
|
# URL prefix (eg. `https://api.example.tld/library/...`) set `API_PREFIX` to
|
||||||
|
# that prefix (example: `/library`) so incoming requests are rewritten to the
|
||||||
|
# application root. This keeps route definitions unchanged while supporting
|
||||||
|
# both proxied and direct deployments.
|
||||||
|
_api_prefix_raw = os.getenv("API_PREFIX", "").strip()
|
||||||
|
api_prefix = ""
|
||||||
|
if _api_prefix_raw:
|
||||||
|
if not _api_prefix_raw.startswith("/"):
|
||||||
|
_api_prefix_raw = "/" + _api_prefix_raw
|
||||||
|
api_prefix = _api_prefix_raw.rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
@app.middleware("http")
|
||||||
|
async def _strip_api_prefix(request, call_next):
|
||||||
|
if api_prefix and request.url.path.startswith(api_prefix):
|
||||||
|
new_path = request.url.path[len(api_prefix) :]
|
||||||
|
request.scope["path"] = new_path or "/"
|
||||||
|
request.scope["root_path"] = api_prefix
|
||||||
|
return await call_next(request)
|
||||||
|
|
||||||
|
|
||||||
# Allow PHP application to call this API
|
# Allow PHP application to call this API
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
|
|||||||
Reference in New Issue
Block a user