echo-swagger
echo-swagger copied to clipboard
oauth2-redirect.html with query parameters return 404
Hi, when I try to login oauth2 feature, it is redirection to this URL:
http://localhost:3000/swagger/oauth2-redirect.html?state=U3X..
But when I checked, if any query parameters go to this html oauth2-redirect.html route not found and return 404.
This should be bug and need to fix the route, serve steps.
v1.3.5 works fine with oauth2 redirection.
I faced the same issue, the bug is in default case of switch statement of swagger.go, line 191
I suggest creating a fork and changing code in default case to:
parsedUrl, err := url.Parse(matches[2])
if err != nil {
c.Error(err)
return nil
}
c.Request().URL = parsedUrl
http.FileServer(http.FS(swaggerFiles.FS)).ServeHTTP(c.Response(), c.Request())
BTW: this issue is mentioned also here: https://github.com/swaggo/swag/issues/1117
I made a PR for the suggested fix after testing it successfully in my fork.