Console Error: Failed response: 415

Created on 13 March 2025, 25 days ago

Problem/Motivation

I have installed and configured the module, but there are a few console errors appearing. Please check if there's a quick fix. Thanks!

Console Error:

Error: Failed response: 415
Autologout has been destroyed.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡΅πŸ‡°Pakistan kaleemullah924

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @kaleemullah924
  • πŸ‡΅πŸ‡°Pakistan kaleemullah924

    The error occurs when I log in.

  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    Hmm 415 status code; Unsupported Media Type is not an error that is thrown by this module. I have not been able to reproduce which indicatest that this is not even thrown by Drupal, but I cannot say that by 100% certainty.
    What does Drupal log when this happens? Is it consistent?

    How ever, the JS in this module does not specify the requested contenttype that might make some servers och firewalls or similar throw the error.

    An obvious improvment would be to have the fetch in the JS script be more specific of what its asks for. I will put that in the the queue improvments. Maybe that would solve your problem...

  • Merge request !2specify format json in js request β†’ (Merged) created by andersmosshall
  • Pipeline finished with Skipped
    25 days ago
    #447712
  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    Added patch for proposed fix of specify content-type in the JS requests. Even if this does not fix the issue this is a obvious improvment that will go out in the next release.

  • πŸ‡΅πŸ‡°Pakistan kaleemullah924

    Thank you for adding the patch to specify the Content-Type in the JS requests. I have applied the patch and cleared the cache, but unfortunately, the issue still persists.

  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    Thank you for the feedback. Can you please provide more info about the issue. Like inspect the networktab for clues of what is throwing this error. And check in Drupal logs to get clues of what is causing the error. As mentioned the module does not explicitly throw any 415 error so there must be something else interfering, either deeper level drupal or server infra.

  • πŸ‡΅πŸ‡°Pakistan kaleemullah924

    Please find the attached screenshot of the Network tab. Additionally, the Drupal log displays the following error:

    Client error:
    "Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException: No route found that matches 'Content-Type: application/json' in Drupal\Core\Routing\ContentTypeHeaderMatcher->filter() (line 49 of /var/www/html/docroot/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php)"

  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    Ok, thats good. That actuall points to an error thrown in drupal which makes this more likely to be able to solve within the module. In what drupal version do you get this error? I have not yet been able to reproduce this error.

    If you come to think of any other debug info that would be good to know investiating this to narrow down the issue it would be much helpful.
    For example
    What drupal version?
    What browser are you using?
    Do you get same issue on different browser? (All though I dont think this is a client side error but it could be a combination)

  • πŸ‡΅πŸ‡°Pakistan kaleemullah924

    The issue occurs in Drupal version 10.4.3 and is present across multiple browsers, including Chrome, Firefox, and Safari.

  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    I can still not reproduce this issue so Im navigating in blind here a bit. But looking at the code in the ContentTypeHeaderMatcher.php it looks for a _content_type_format requirement. How ever if no requirement are set it should fallback on the match that Drupal has already set. Which happens for me.

    The only way that it makes sence is if you have a module that by hook modifes the _content_type_format req for routes making this match not empty hence invalidates it.

    That being said it makes sence that my module set the _content_type_format req for the patch route so I upload a patch here for you to try. This patch replaces the last uploaded patch (FYI).

    On the other hand if there are hooks modifying the _content_type_format req it may very well be overwritten and making this module definition irrelevant anywayh but it is worth a shot.

  • πŸ‡΅πŸ‡°Pakistan kaleemullah924

    I applied patch #14, but it didn't resolve the issue.

  • πŸ‡ΈπŸ‡ͺSweden andersmosshall

    Thanks for checking.

    Then Im literally out of clues of whats causing this issue unless there is some module completely overwriting the _content_type_format req for autologout_alterable's routes. Drupal core does not modify them at least, that much I can tell. And I have not been able to reproduce this on drupal 10.4.3.

    I cannot investigat this further because I cannot reproduce. I leave this ticket open for a while longer if you or anyone else having this issue have the possibility to investigate.
    I'd suggest if possible to spin up xdebug and check the code in /core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php and before to see why the error is thrown and where the constraints are modified, if done so.

    The changes made so far though are obvious improvments of the module and will most likely be part of next release of this module.

    Thanks for reporting this bug, sorry that it does not seems to be a quick fix.

  • Pipeline finished with Skipped
    18 days ago
    #452914
Production build 0.71.5 2024