Blocked rerouting of URL for jsonapi
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3408255. -->
Reported by: [ridefree](https://www.drupal.org/user/49148)
Related to !3
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Originally posted this issue in JSON:API here: <a href="https://www.drupal.org/project/drupal/issues/3407746">https://www.drupal.org/project/drupal/issues/3407746</a></p>
<p>Our development site this is on hasn't updated to 10.x yet so we are using the 1.0.2 version of the module on 9.5.11. It is a multilingual site. </p>
<p>The issue:<br>
With the module installed, when navigating to a URL like <a href="https://sitenme.org/jsonapi/">https://sitenme.org/jsonapi/</a> we expect the path to redirect to <a href="https://sitename.org/en/jsonapi">https://sitename.org/en/jsonapi</a>. It doesn't and instead gives a 500 error in the browser. </p>
<p><code>{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"errors":[{"title":"Internal Server Error","status":"500","detail":"Syntax error","links":{"via":{"href":"https:\/\/branch-sitename.pantheonsite.io\/jsonapi\/"},"info":{"href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.5.1"}}}]}</code></p>
<p>and in the logs it gives:</p>
<p><code>JsonException: Syntax error in json_decode() (line 120 of /code/web/modules/contrib/json_api_book/src/EventSubscriber/ResponseSubscriber.php).</code></p>
<p>I believe the 1.1.x and 1.0.2 are using the same code, but I haven't tested this on a D10 site yet. </p>
<p>NOTE: The same issue happens when navigating to <a href="https://sitenme.org/en/jsonapi/">https://sitenme.org/en/jsonapi/</a>, it doesn't remove the trailing "/", so it may not be just with multilingual sites. </p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ol>
<li>Drupal 9.5.11 site with JSON:API enabled and multilingual enabled</li>
<li>JSON:API Book module enabled</li>
<li>Navigate in a browser to <a href="https://sitenme.org/jsonapi/">https://sitenme.org/jsonapi/</a> </li>
</ol>
issue