Skip to content

Redirection error when using AddTrailingSlash middleware #108

Open
@Trowsing

Description

@Trowsing

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 [email protected]

// @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"))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions