echo-swagger icon indicating copy to clipboard operation
echo-swagger copied to clipboard

oauth2-redirect.html with query parameters return 404

Open rytsh opened this issue 2 years ago • 3 comments

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.

rytsh avatar May 21 '23 18:05 rytsh

I faced the same issue, the bug is in default case of switch statement of swagger.go, line 191 image

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

komron-m avatar Sep 20 '23 11:09 komron-m

I made a PR for the suggested fix after testing it successfully in my fork.

reidlevesque avatar Jul 31 '24 15:07 reidlevesque