Skip to content

Commit fc948b9

Browse files
committed
[chores:fix] Fixed radius batch RADIUS_API_BASEURL #608
We recently introduced websocket routes but forgot to allow connecting a different host specified in RADIUS_API_BASEURL. Related to #608
1 parent 9da66a5 commit fc948b9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

openwisp_radius/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ def change_view(self, request, object_id, form_url="", extra_context=None):
435435
if RADIUS_API_BASEURL:
436436
batch_pdf_api_url = urljoin(RADIUS_API_BASEURL, batch_pdf_api_url)
437437
extra_context["download_rad_batch_pdf_url"] = batch_pdf_api_url
438+
extra_context["RADIUS_API_BASEURL"] = RADIUS_API_BASEURL
438439
return super().change_view(
439440
request,
440441
object_id,

openwisp_radius/templates/openwisp-radius/admin/rad_batch_users_change_form.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
if (batchStatus === "processing") {
4949
const batchId = "{{ original.pk }}";
5050
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
51-
const wsPath = protocol + "//" + window.location.host + "/ws/radius/batch/" + batchId + "/";
51+
{% if RADIUS_API_BASEURL != "/" %}
52+
const baseUrl = "{{ RADIUS_API_BASEURL }}";
53+
{% else %}
54+
const baseUrl = protocol + "//" + window.location.host;
55+
{% endif %}
56+
const wsPath = baseUrl + "/ws/radius/batch/" + batchId + "/";
5257
const socket = new WebSocket(wsPath);
5358

5459
socket.onmessage = function(e) {

0 commit comments

Comments
 (0)