You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
moduleMyAppclassRoutes < Hanami::Routesroot{"Hello from MyApp-server"}slice:payments,at: "/payments"douse:body_parser,:json# json body-parser should be used for all payments-requests.scope:authdopost"/login",to: "auth.login"endscope:graphqldouseMyApp::Middlewares::Authorizationpost"/api",to: "graphql.api"endendendend
It is expected that the json-body-parser is applied to all payment requests, regardless if payments/auth/login or payments/graphql/api is requested. But that's not the case. The body payload of a payments/auth/login is not parsed and fails. A request to payments/graphql/api is parsed and runs through the MyApp::Middlewares::Authorization-middlware.
If I remove the MyApp::Middlewares::Authorization-middleware, the body-parsing for payments/auth/login and payments/graphql/api works as expected.
To make it work, I had to change the routes to following:
moduleMyAppclassRoutes < Hanami::Routesroot{"Hello from MyApp-server"}slice:payments,at: "/payments"doscope:authdouse:body_parser,:json# json body-parser should be used for all payments-requests.post"/login",to: "auth.login"endscope:graphqldouse:body_parser,:json# json body-parser should be used for all payments-requests.useMyApp::Middlewares::Authorizationpost"/api",to: "graphql.api"endendendend
Hey 👋 ,
I have following routes:
It is expected that the json-body-parser is applied to all payment requests, regardless if
payments/auth/login
orpayments/graphql/api
is requested. But that's not the case. The body payload of apayments/auth/login
is not parsed and fails. A request topayments/graphql/api
is parsed and runs through theMyApp::Middlewares::Authorization
-middlware.user@6beeaaf00e22:~/app$ bin/hanami middleware / Dry::Monitor::Rack::Middleware (instance) / Rack::Session::Cookie /payments Hanami::Middleware::BodyParser /payments/graphql PayNRed::Middlewares::Authorization
If I remove the
MyApp::Middlewares::Authorization
-middleware, the body-parsing forpayments/auth/login
andpayments/graphql/api
works as expected.To make it work, I had to change the routes to following:
user@6beeaaf00e22:~/app$ bin/hanami middleware / Dry::Monitor::Rack::Middleware (instance) / Rack::Session::Cookie /payments/auth Hanami::Middleware::BodyParser /payments/graphql Hanami::Middleware::BodyParser /payments/graphql PayNRed::Middlewares::Authorization
Is this the expected behavior?
Thanks and best regards
The text was updated successfully, but these errors were encountered: