iridakos / duckrails

Development tool to mock API endpoints quickly and easily (docker image available)
https://github.com/iridakos/duckrails/wiki
MIT License
1.72k stars 108 forks source link

Overwriting headers in Advanced causes 500 #49

Open zdrummond opened 5 years ago

zdrummond commented 5 years ago

DuckRails 2.1.9 Running on Docker

I was just playing around, and wanted to dynamically change responses headers. When I tried returning a JSON object with a headers key I get a 500: "We're sorry, but something went wrong".

To validate that I was writing the JS correctly, I just grabbed your example code for the response body, added the headers key and returned it.

Here is the code

var date = new Date();
date.setDate(date.getDate() -  Math.floor(Math.random() * 30 + 1) );

var obj = {
 "headers":{
       "current_page": Math.floor((Math.random() * 456) + 1),
        "started_reading": date.toDateString()
   }
}

return JSON.stringify(obj);

Expected: Headers would now have a current_page and started_reading key in my curl.

Actual: Return code 500, HTML with

<div class="dialog">
    <div>
      <h1>We're sorry, but something went wrong.</h1>
    </div>
    <p>If you are the application owner check the logs for more information.</p>
  </div>