<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 18, 2022 at 9:37 PM Francis Daly <<a href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Nov 18, 2022 at 07:07:41PM +0530, Kaushal Shriyan wrote:<br>
> On Thu, Nov 17, 2022 at 10:57 PM Francis Daly <<a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a>> wrote:<br>
<br>
Hi there,<br>
<br>
> Please let me know if you need any additional information and I look<br>
> forward to hearing from you. Thanks in advance.<br>
<br>
When the request is for "/apis/unique_id", what file on the filesystem<br>
do you want nginx to ask drupal to use?<br>
<br></blockquote><div><br></div><div><div>Thanks Francis for your email response. Let me explain with two different scenarios :- </div></div></div><div class="gmail_quote"><br><u>Scenario 1 </u></div><div class="gmail_quote">500 errors occurred in any random page of the site for example - <a href="https://mydrupalsite.com/randompath">https://mydrupalsite.com/randompath</a> , in that case we want Nginx to provide an HTML error page. And this is working as we have set up a custom HTML page and configured Nginx 500 error to point to that HTML page. We don't have any issue here<br><br></div><div class="gmail_quote"><u>Scenario 2 </u></div><div class="gmail_quote">500 error occurred when the user tried to access the page - <a href="https://mydrupalsite.com/apis">https://mydrupalsite.com/apis</a> or <a href="https://mydrupalsite.com/apis/unique_id">https://mydrupalsite.com/apis/unique_id</a> . Here we want a json response that Drupal is sending. Now we can't say what specific file Nginx should use in this case to display the JSON response. As when a user is trying to access these pages , in the backend , to serve this request Drupal is processing N number of files, now among those files in any file that 500 exceptions can occur. At code level we are just handling that and sending JSON responses. Like below.<br>try{<br> $node_new->save();<br> }<br> catch(\Exception $e) {<br> $output = [<br> "type" => "/problems/API-saving-error",<br> "title" => $this->t("Issue occurred while saving the API."),<br> "detail" => $this->t("There are some wrong inputs passed to DB which caused this issue."),<br> ];<br> return new JsonResponse($output, 500);<br> }<br><br>So here you can see that we handled and sent the JSON response , now we can't tell Nginx which file we want to present , as the JSON response can come from any file where 500 exceptions are handled. (edited) <br><br>And moreover the content of the JSON response also varies based on the reason behind that 500 exception, as we try to give relevant messages to the user , so if 500 errors occurred in any other php file the JSON response content can be different.<br><br>So we want Nginx to display this JSON response whatever Drupal is sending instead presenting the default HTML page which is configured for 500 error<br><br>So , it's not like that we need to tell Nginx what file of the filesystem Nginx can use to display 500 error for <a href="https://mydrupalsite.com/apis">https://mydrupalsite.com/apis</a> or <a href="https://mydrupalsite.com/apis/unique_id">https://mydrupalsite.com/apis/unique_id</a>, rather we want Nginx to display whatever Drupal is sending. And it can be easily achieved if we don't configure 500 error pages at Nginx , in that case whatever Drupal is ending that only will be displayed. Problem is that we have to keep that 500 error page configuration at Nginx and at the same Nginx should not use that error page for these two types of URLs- <a href="https://mydrupalsite.com/apis">https://mydrupalsite.com/apis</a> or <a href="https://mydrupalsite.com/apis/unique_id">https://mydrupalsite.com/apis/unique_id</a><br><div> </div><div><div><div>Please let me know if you need any additional information and I look forward to hearing from you. Thanks in advance. </div></div><div><br></div><div>Best Regards,</div><div><br></div><div>Kaushal </div></div><div><br></div></div></div>