drawio icon indicating copy to clipboard operation
drawio copied to clipboard

Hosting in a subpath doesn't correctly serve assets

Open MichaelGerhart opened this issue 3 years ago • 0 comments

Preflight Checklist

  • [x] I agree to follow the Code of Conduct that this project adheres to.
  • [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Describe the bug When hosting drawio in a subpath 'https://sub.domain.com/-/drawio', assets like preconfig.js are served at the root url / instead of the subpath https://sub.domain.com/-/drawio

However, if you trail the url with / they populate correctly. IE https://sub.domain.com/-/drawio/

To Reproduce Steps to reproduce the behavior:

  1. Deploy drawio in a subpath
  2. attempt to visit the url without a trailing /

Expected behavior drawio should be able to correctly populate asset paths when hosted in a subpath.

Screenshots

Screen Shot 2022-09-15 at 2 58 03 PM

Screen Shot 2022-09-15 at 3 00 37 PM

draw.io version (In the Help->About menu of the draw.io editor):

  • draw.io version 20.2.8

Additional Info

We are hosting this in kubernetes, this is our configuration

apiVersion: v1
kind: Service
metadata:
  name: drawio
  namespace: gitlab
  labels:
    app: draw.io
spec:
  type: ClusterIP
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 3600
  ports:
  - name: http
    port: 8080
  selector:
    app: draw.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: drawio
  namespace: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      app: draw.io
  template:
    metadata:
      labels:
        app: draw.io
    spec:
      containers:
      - image: redacted.com/combined-docker-virtual/jgraph/drawio:20.2.8
        imagePullPolicy: Always
        name: drawio
        resources:
          limits:
            cpu: 200m
            memory: 512Mi
          requests:
            cpu: 50m
            memory: 128Mi
        ports:
        - containerPort: 8080
        env:
        # Enable GitLab storage.
        - name: gl
          value: "1"
        - name: DRAWIO_GITLAB_ID
          value: "redacted"
        - name: DRAWIO_BASE_URL
          value: "https://sub.domain.com/-/drawio"
        - name: DRAWIO_GITLAB_URL
          value: "redacted"
        - name: DRAWIO_GITLAB_SECRET
          value: "redacted"
        - name: DRAWIO_CSP_HEADER
          value: "default-src \\'self\\'; script-src \\'self\\' https://*.redacted.com https://*.redacted.com/-/drawio https://storage.googleapis.com https://apis.google.com https://docs.google.com https://code.jquery.com \\'unsafe-inline\\'; connect-src \\'self\\' https://*.dropboxapi.com https://api.trello.com https://api.github.com https://raw.githubusercontent.com https://*.googleapis.com https://*.googleusercontent.com https://graph.microsoft.com https://*.1drv.com https://*.sharepoint.com https://gitlab.com https://*.redacted.com https://*.redacted.com/-/drawio https://*.google.com https://fonts.gstatic.com https://fonts.googleapis.com; img-src * data:; media-src * data:; font-src * about:; style-src \\'self\\' \\'unsafe-inline\\' https://fonts.googleapis.com; frame-src \\'self\\' https://*.google.com;"
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: drawio
  namespace: gitlab
  labels:
    app: draw.io
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  tls:
    - secretName: cnc-glab-digicert
  rules:
    - host: sub.domain.com
      http:
        paths:
          - path: /-/drawio(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: drawio
                port:
                  number: 8080

MichaelGerhart avatar Sep 15 '22 19:09 MichaelGerhart