go-aah / aah

A secure, flexible, rapid Go web framework
https://aahframework.org
MIT License
690 stars 33 forks source link

Route param 'redirect_trailing_slash' can create redirect loop #259

Closed joelsdc closed 4 years ago

joelsdc commented 5 years ago

What version of aah are you using (aah --version)?

v0.12.3

Does this issue reproduce with the latest release?

Yes.

What operating system are you using (such as macOS, Linux and Windows)?

macOS (haven't verified on other systems)

What did you do?

  1. Create a simple service, with a subroute (/something/:xxx)

Example routes.conf:

    routes {
      test {
        path = "/test/:something"
        controller = "SomeController"
        action = "SomeAction"
        }
      }
    }
  1. Routes.conf redirect_trailing_slash must be set to true.
  2. Make a request to .../test

What did you expect to see?

Expected:

GET http://localhost:8080/test --> Route not found, Host: localhost:8080, Path: /test

What did you see instead?

A redirect-loop:

GET http://localhost:8080/test --> 

RedirectTrailingSlash: 302, /test ==> http://localhost:8080/test/
Redirecting to 'http://localhost:8080/test/' with status '302'

And now if we do:

GET http://localhost:8080/test/ --> 

RedirectTrailingSlash: 302, /test/ ==> http://localhost:8080/test
Redirecting to 'http://localhost:8080/test' with status '302'

So http://localhost:8080/test gets redirected to http://localhost:8080/test/ and again http://localhost:8080/test/ to http://localhost:8080/test

Additional context

WORKAROUND: I'm not even sure if this is a bug or expected, but setting routes.conf redirect_trailing_slash to false solves this.

jeevatkm commented 5 years ago

@joelsdc This is expected behavior in redirect trailing slash feature.

jeevatkm commented 4 years ago

@joelsdc I hope you're doing well. I'm trying to wrap up the v0.13.0 release. Did fixes and enhancements. Then I will be moving on to aah revamp on v0.14.0

Can you please validate this issue against the branch wrapping-v0.13.0 and let me know?