Strange behaviour of ImplicitOptionsMiddleware with multiple route on same path

To me it doesn’t seem to be fixed :disappointed_relieved: I continue to get only ONE method allowed.

These are the versions I’m using right now:

zendframework/zend-expressive 2.1.1
zendframework/zend-expressive-router 2.4.1
zendframework/zend-expressive-zendrouter 2.2.0

Are you getting a 405 response status, or a 200 response status in this particular case?

The reason I ask is because the logic in the RouteMiddleware is such that it might respond before the ImplicitOptionsMiddleware is even reached. In that case, it might not be aggregating the allowed methods correctly.

Additionally, the changes where I was able to verify that the allowed methods were aggregating correctly in the v2 series were with FastRoute; this may not be true with zend-router.

I’m getting a 200 response status.

Access-Control-Allow-Headers →Authorization, Content-Type, Accept
Allow →PUT
Connection →Keep-Alive
Content-Length →0
Content-Type →text/html; charset=UTF-8
Date →Mon, 12 Mar 2018 15:18:31 GMT

I’m using Zend\Expressive\Middleware\ImplicitOptionsMiddleware and the routes configuration defined at the beginning of the post.

@matthew Do you recommend to use FastRoute instead of ZendRoute?

I personally prefer it as it allows me to define my constraints in-place, within the URI string. Additionally, we know that it’s reporting the HTTP methods properly in both v2 and v3.

That said, I also know that refactoring your routing between routers is not trivial. V3 fixes the issues across all routers, and that may be your best bet.

1 Like

If anyone is interested in zend expressive 3 the problem has been fixed!

1 Like