replay route: (prepare for replay, #124)
- add support for /replay/sw.js - ensure route works in both k8s and docker (routed via main nginx)
This commit is contained in:
parent
be86505347
commit
523b557eac
@ -5,7 +5,7 @@ supports docker and kubernetes based deployments of multiple browsertrix-crawler
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI, Response
|
||||||
|
|
||||||
from db import init_db
|
from db import init_db
|
||||||
|
|
||||||
@ -94,6 +94,13 @@ def main():
|
|||||||
async def healthz():
|
async def healthz():
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@app.get("/replay/sw.js")
|
||||||
|
async def replay_sw():
|
||||||
|
return Response(
|
||||||
|
content='importScripts("https://cdn.jsdelivr.net/npm/replaywebpage@1.5.7/sw.js");',
|
||||||
|
media_type="application/javascript",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
|
@ -50,7 +50,7 @@ spec:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
- name: BACKEND_HOST
|
- name: BACKEND_HOST
|
||||||
value: {{ .Values.name }}-frontend
|
value: {{ .Values.name }}-backend
|
||||||
|
|
||||||
- name: BROWSER_SCREENCAST_URL
|
- name: BROWSER_SCREENCAST_URL
|
||||||
value: http://$2.crawlers.svc.cluster.local:9037
|
value: http://$2.crawlers.svc.cluster.local:9037
|
||||||
|
@ -53,6 +53,12 @@ server {
|
|||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /replay/ {
|
||||||
|
proxy_pass http://${BACKEND_HOST}:8000;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
# used by docker only: k8s deployment handles /api directly via ingress
|
# used by docker only: k8s deployment handles /api directly via ingress
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://${BACKEND_HOST}:8000/;
|
proxy_pass http://${BACKEND_HOST}:8000/;
|
||||||
|
Loading…
Reference in New Issue
Block a user