I have a code that after make a DELETE query in mysql it makes a redirect to other endpoint (the same app) but sometime it makes a Bad Gateway Error 502. I don't understand why, it started some weeks ago but I couldn't find the problem. The code that I use to redirect is:
return redirect(url_for('panel_usuario'))
The image that I see in the browser is:

It may be a problem of PAW or Cloudfare. Notice that I didn't make a change about DNS, cloudflare or something related to the server.