Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirection error when using AddTrailingSlash middleware #108

Open
Trowsing opened this issue Jun 7, 2023 · 0 comments
Open

Redirection error when using AddTrailingSlash middleware #108

Trowsing opened this issue Jun 7, 2023 · 0 comments

Comments

@Trowsing
Copy link

Trowsing commented Jun 7, 2023

Current Behavior

When AddTrainlingSlash middleware is used, the swagger route starts an infinite redirection loop resulting in ERR_TOO_MANY_REDIRECTS on the browser. It happens with both index.html and doc.json routes.

Steps to reproduce

  1. Follow the usage instructions and add the AddTrailingSlash middleware to the app:
package main

import (
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	echoSwagger "github.com/swaggo/echo-swagger"
)

// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host petstore.swagger.io
// @BasePath /v2
func main() {
	e := echo.New()

	e.Pre(middleware.AddTrailingSlash())

	e.GET("/swagger/*", echoSwagger.WrapHandler)

	e.Logger.Fatal(e.Start(":1323"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant