[GH-ISSUE #2567] hard coded path won't work if you use a path prefix #1639

Closed
opened 2026-02-27 11:18:17 +03:00 by kerem · 4 comments
Owner

Originally created by @gawel on GitHub (Jul 20, 2022).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/2567

Impacted versions

  • OS Type: Debian
  • OS Version: Bullseye
  • Database Type: MySQL
  • Database version: X.y
  • Modoboa: 2.0.1
  • installer used: No
  • Webserver: Apache

Steps to reproduce

Create a urls.py file and use it in your settings:

from django.conf.urls import include, url

urlpatterns = [
    url(r'^manager/', include('modoboa.urls')),
]

Current behavior

There is some hard coded links in the js files. At least for the 2FA auth: github.com/modoboa/modoboa@fda59b51e1/modoboa/static/js/twocols_nav.js (L180)

But the real url is /manager/api/... so the ajax request fail with a 404

Same problem with the new vuejs UI. Everything is expected to be at /new-admin/ but we need /manager/new-admin. I guess this one can be fixed with sed

Expected behavior

Api calls should work even if we use a prefix

A solution is to define a js variable with the correct prefix. Something like:

window.API_ROOT = "{% url api_root %}"

And use this var in the js files.

Originally created by @gawel on GitHub (Jul 20, 2022). Original GitHub issue: https://github.com/modoboa/modoboa/issues/2567 # Impacted versions * OS Type: Debian * OS Version: Bullseye * Database Type: MySQL * Database version: X.y * Modoboa: 2.0.1 * installer used: No * Webserver: Apache # Steps to reproduce Create a urls.py file and use it in your settings: ``` from django.conf.urls import include, url urlpatterns = [ url(r'^manager/', include('modoboa.urls')), ] ``` # Current behavior There is some hard coded links in the js files. At least for the 2FA auth: https://github.com/modoboa/modoboa/blob/fda59b51e1ef7f57f3601015dcdc2693f7f7efe8/modoboa/static/js/twocols_nav.js#L180 But the real url is `/manager/api/...` so the ajax request fail with a 404 Same problem with the new vuejs UI. Everything is expected to be at `/new-admin/` but we need `/manager/new-admin`. I guess this one can be fixed with sed # Expected behavior Api calls should work even if we use a prefix A solution is to define a js variable with the correct prefix. Something like: ``` window.API_ROOT = "{% url api_root %}" ``` And use this var in the js files.
kerem 2026-02-27 11:18:17 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ksaadDE commented on GitHub (Jul 25, 2022):

Could you create a patch + PR for this?

To my understanding of reading it for a few seconds, it might be a variable change in the files, since it is hardcoded right?

<!-- gh-comment-id:1194631411 --> @ksaadDE commented on GitHub (Jul 25, 2022): Could you create a patch + PR for this? To my understanding of reading it for a few seconds, it might be a variable change in the files, since it is hardcoded right?
Author
Owner

@gawel commented on GitHub (Aug 18, 2022):

PR done for the tfa stuff. Looks likes a postgres test is failing because of... mysql. Not sure how to fix that

<!-- gh-comment-id:1219543232 --> @gawel commented on GitHub (Aug 18, 2022): PR done for the tfa stuff. Looks likes a postgres test is failing because of... mysql. Not sure how to fix that
Author
Owner

@ksaadDE commented on GitHub (Aug 24, 2022):

PR done for the tfa stuff. Looks likes a postgres test is failing because of... mysql. Not sure how to fix that

@tonioo

<!-- gh-comment-id:1226586706 --> @ksaadDE commented on GitHub (Aug 24, 2022): > PR done for the tfa stuff. Looks likes a postgres test is failing because of... mysql. Not sure how to fix that @tonioo
Author
Owner

@tonioo commented on GitHub (Sep 5, 2022):

For the record, it's not possible to conditionally start services with GHA (see https://github.com/actions/runner/issues/822)

<!-- gh-comment-id:1237010402 --> @tonioo commented on GitHub (Sep 5, 2022): For the record, it's not possible to conditionally start services with GHA (see https://github.com/actions/runner/issues/822)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1639
No description provided.