From e1a2b0a27cb498fe347b65a4345492026f9802ec Mon Sep 17 00:00:00 2001 From: Grant Petersen-Speelman Date: Sun, 7 Jan 2024 21:50:29 +1100 Subject: [PATCH] Rewind the body before reading it (#150) * Rewind the body before reading it * Update CHANGELOG.md --- CHANGELOG.md | 3 ++- lib/cypress_on_rails/middleware.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a114f..326b120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ * Removed the update generator and reduced options for install generator [PR 149](https://github.com/shakacode/cypress-on-rails/pull/149) ### Fixed -* fix update index.js in install generatpr [PR 147](https://github.com/shakacode/cypress-on-rails/pull/147) by [Judahmeek] +* fix update index.js in install generator [PR 147](https://github.com/shakacode/cypress-on-rails/pull/147) by [Judahmeek] * Support rails 7.1 by adding content-type header to generated on-rails.js file [PR 148](https://github.com/shakacode/cypress-on-rails/pull/148) by [anark] +* Rewind body before reading it [PR 150](https://github.com/shakacode/cypress-on-rails/pull/150) ## [1.16.0] [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.15.1...v1.16.0 diff --git a/lib/cypress_on_rails/middleware.rb b/lib/cypress_on_rails/middleware.rb index f9620b0..f5ed274 100644 --- a/lib/cypress_on_rails/middleware.rb +++ b/lib/cypress_on_rails/middleware.rb @@ -51,6 +51,7 @@ def handle_command(req) # Halt the middleware if an Rack Env was returned by `before_request` return maybe_env unless maybe_env.nil? + req.body.rewind body = JSON.parse(req.body.read) logger.info "handle_command: #{body}" commands = Command.from_body(body, configuration)