-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting ASGI message error when using an URL prefix #2468
Comments
I wasn't able to reproduce it using the subpath example https://github.com/zauberzeug/nicegui/blob/main/nicegui/middlewares.py |
I finally had time to look into this but could not quickly create a test setup. Could you share a minimal reproducible example? Why do you supply Lines 14 to 16 in 9dd03ee
|
The error may very well be caused by the same problem as in #2515, which hopefully gets fixed with my pull request in the python-engineio repository. |
I tried to make a docker compose that do the same as our k8s and adapt the nginx_subpath example with it. changes in nginx.conf
changes in docker-compose.yml image: zauberzeug/nicegui:1.4.7
environment:
PATH_PREFIX: "/nicegui"
volumes:
- ./app:/app # mount local app directory
command: ["uvicorn", "--host", "0.0.0.0", "--port", "8080", "--root-path", "/nicegui", "main:app"] changes in app/main.py from nicegui import ui
from starlette.middleware.sessions import SessionMiddleware
from fastapi import FastAPI
app = FastAPI(
title="Minimal example for prefix root_path",
)
def init(app: FastAPI) -> None:
app.add_middleware(SessionMiddleware, secret_key="is_this_working?")
@ui.page('/subpage')
def subpage():
ui.label('This is a subpage')
ui.button('back', on_click=lambda: ui.open('/'))
@ui.page('/')
def index():
ui.button("go to subpage", on_click=lambda: ui.open('/subpage'))
init(app)
ui.run_with(app) Some relevant fragment of the k8s ingress config annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /$2
rules:
- host: our.company.com
http:
paths:
- path: /nicegui(/|$)(.*)
pathType: Prefix
backend:
service:
name: app-dev
port:
number: 80
The nginx conf still has some issues as moving from But the core is running alongside FastAPI and using uvicorn with |
Description
Since version higher than 1.4.7, I can no longer make nicegui works when using a custom URL prefix.
Basically it's the same error as #2354, #2368 and #2370.
When I try locally, without prefix, this work perfectly. All dependencies are identical between local and production. The only diff is that in prod, the app is behind a reverse proxy with a prefix for the URL.
wss://company.domain/subdomain/subsubdomain/subsubsubdomain/_nicegui_ws/socket.io/?client_id=REDACTED&transport=websocket
.I'm not knowledgeable with socketio, but the fix that set the
socketio_path
seem to use absolute URL here.The current way of using custom prefix is by using the
request
object here but the same trick seem impossible at startup.The text was updated successfully, but these errors were encountered: