Good morning, please I have implemented a websocket in my django app where the websocket url has a u_id , however if the websocket fails the browser console display the url with the uid which is a security concern. Please I need your helps on how to handle or customize the error so that I will able to display my own custom message error in the browser console.
here is my views.py
@staticmethod
def random_qr_code(request):
context = {}
request_url = get_current_host(request)
u_id = str(uuid.uuid4()).replace('-', "")
u_id = u_id[:7].upper()
octal_str = get_encoded_data()
image = octal_qr_code(octal_str)
CrossAuth.objects.create(token=u_id, seed=octal_str)
url = f"ws://{request_url}/ws/auth_qr_code/{u_id}/"
context["image_url"] = image
context["url"] = url
context["secret_key"] = octal_str
return context
htm file
<script>
const socket = new WebSocket("{{ url }}");
let timer = null;
socket.onopen = () => {};
socket.onmessage = function (evt) {
console.log(evt["data"]);
document.getElementById("success_message").innerHTML = evt["data"];
window.location.href =
"{{ request.scheme }}://{{ request.get_host }}/success_mobile/";
};
socket.onclose = socket.onerror = () => {};
</script>
here is the error from the browser
In this you can see the websocket displays the UUID and I want to remove it.
Note: I have tried to avoid passing the UUID to the url it works fine, however I need to maintain the uid in the url to avoid any prod issue.
Thank you for your helps and valuable time.