From 68dc095c835efd3e53e4bedc071cc66024541f22 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Sun, 23 Mar 2025 20:10:43 -0700 Subject: [PATCH] Do not redirect API requests to login page Fixes #2490 --- plexpy/webauth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plexpy/webauth.py b/plexpy/webauth.py index c4b83ab7..67658d15 100644 --- a/plexpy/webauth.py +++ b/plexpy/webauth.py @@ -176,7 +176,10 @@ def check_auth(*args, **kwargs): raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) else: - redirect_uri = cherrypy.request.wsgi_environ['REQUEST_URI'] + if cherrypy.request.headers.get('X-Requested-With') == 'XMLHttpRequest': + raise cherrypy.HTTPError(401) + + redirect_uri = cherrypy.request.path_info if redirect_uri: redirect_uri = '?redirect_uri=' + quote(redirect_uri)